Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t.i.t.deferLater() callable argument should be optional #9577

Closed
twisted-trac opened this issue Jan 20, 2019 · 4 comments
Closed

t.i.t.deferLater() callable argument should be optional #9577

twisted-trac opened this issue Jan 20, 2019 · 4 comments

Comments

@twisted-trac
Copy link

twm's avatar @twm reported
Trac ID trac#9577
Type enhancement
Created 2019-01-20 01:41:03Z
Branch https://github.com/twisted/twisted/tree/9577-deferLater-no-callback

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:

  1. It doesn't implement cancellation (while deferLater does).
  2. 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.

Searchable metadata
trac-id__9577 9577
type__enhancement enhancement
reporter__twm twm
priority__normal normal
milestone__None None
branch__9577_deferLater_no_callback 9577-deferLater-no-callback
branch_author__ 
status__closed closed
resolution__fixed fixed
component__core core
keywords__None None
time__1547948463530949 1547948463530949
changetime__1554786206341084 1554786206341084
version__None None
owner__twm twm

@twisted-trac
Copy link
Author

twm's avatar @twm set owner to @twm
@twm set status to assigned

@twisted-trac
Copy link
Author

twm's avatar @twm removed owner
@twm set status to new

PR ready for review: #1094

@twisted-trac
Copy link
Author

glyph's avatar @glyph set owner to @twm

#1094 (review)

@twisted-trac
Copy link
Author

twm's avatar @twm set status to closed

In changeset ee9c5db

#!CommitTicketReference repository="" revision="ee9c5db3b94e1475eec31314bcac93f71501e7a1"
Merge pull request #1094 from twisted/9577-deferLater-no-callback

Author: twm
Reviewer: glyph
Fixes: ticket:9577

Make callback argument to deferLater optional

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants