Ticket #5912 enhancement closed fixed
Explain `d, self.deferred = self.deferred, None` idiom
| Reported by: | tom.prince | Owned by: | exarkun |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | core | Keywords: | documentation |
| Cc: | Branch: | branches/deferred-reference-clearing-5912 | |
| Author: | exarkun | Launchpad Bug: |
Description
This common idiom should be explained.
if self.deferred is not None:
d, self.deferred = self.deferred, None
That code sets d to self.deferred at the same time as setting self.deferred to None. That way, if the code is called again later, then self.deferred, the condition in the if evaluates to False. Also, it gets rid of the reference to the deferred, allow it and all its callbacks (including the captured closures) to be garbage collected.
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

