You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a statement like @mark.timeout(50) there is nothing to say the duration is defined in seconds. This has a few disadvantages:
Many other timing mechanisms use milliseconds or minutes as their units, so we can't simply assume that it's seconds. A new or returning user has to read the documentation (or code) to ascertain this, wasting time and producing cognitive overhead.
Extreme timeouts like 1200 or 0.00005 have more cognitive overhead, since converting to the "natural" unit of minutes/microseconds etc isn't always trivial.
It would be nice if it instead were self-documenting. Some alternatives:
@mark.timeout(seconds=50) would make it pretty obvious, and would make it easy to support several units.
@mark.timeout(timedelta(minutes=5)) would make it more explicit, while supporting the widest possible range of units at no extra cost.
@mark.timeout(seconds=timedelta(minutes=5).total_seconds()) is a clunky workaround.
The text was updated successfully, but these errors were encountered:
marker=item.get_closest_marker(name="timeout")
ifmarker.args:
# Old markeriflen(marker.args) >1:
raiseRuntimeError("The `timeout` marker only accepts one argument.")
ifmarker.kwargs:
raiseRuntimeError("The `timeout` marker does not accept keyword arguments when arguments are passed.")
timeout=timedelta(seconds=marker.args[0])
elifmarker.kwargs:
timeout=timedelta(**marker.kwargs)
else:
raiseRuntimeError("The `timeout` marker needs either argument or keyword arguments passed.")
In a statement like
@mark.timeout(50)
there is nothing to say the duration is defined in seconds. This has a few disadvantages:1200
or0.00005
have more cognitive overhead, since converting to the "natural" unit of minutes/microseconds etc isn't always trivial.It would be nice if it instead were self-documenting. Some alternatives:
@mark.timeout(seconds=50)
would make it pretty obvious, and would make it easy to support several units.@mark.timeout(timedelta(minutes=5))
would make it more explicit, while supporting the widest possible range of units at no extra cost.@mark.timeout(seconds=timedelta(minutes=5).total_seconds())
is a clunky workaround.The text was updated successfully, but these errors were encountered: