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
Right now this is the idiomatic way to generate a Deferred that fires after ten seconds:
from twisted.internet.task import deferLater
d = deferLater(reactor, 10.0, lambda: None)
Instead, we should be able to write:
d = deferLater(reactor, 10.0)
In this case d would fire with None.
The increase in convenience is modest, but non-negligible. In practice every Twisted codebase I adopt has an equivalent function, usually named sleep or asleep. Usually this helper has one of two flaws:
It doesn't implement cancellation (while deferLater does).
It is a wrapper around deferLater, incurring the unnecessary overhead of allocating and calling the callback required by that function.
There is some historical debate about this in #1875.
Right now this is the idiomatic way to generate a
Deferred
that fires after ten seconds:Instead, we should be able to write:
In this case
d
would fire withNone
.The increase in convenience is modest, but non-negligible. In practice every Twisted codebase I adopt has an equivalent function, usually named
sleep
orasleep
. Usually this helper has one of two flaws:deferLater
does).deferLater
, incurring the unnecessary overhead of allocating and calling the callback required by that function.There is some historical debate about this in #1875.
Searchable metadata
The text was updated successfully, but these errors were encountered: