[Twisted-Python] Re: Transparent pooling of deferreds to be fired upon another
andrewfr_ice at yahoo.com
Thu Apr 23 12:24:44 EDT 2009
--- On Thu, 4/23/09, twisted-python-request at twistedmatrix.com
> Suppose I have a function called alertSupervisor that takes
> a string message for the supervisor and which returns a deferred. I
> want to be able to call that function from anywhere in my code, and I
> always want to get a deferred back, but if there's already a call in >progress to tell the supervisor the same thing then I don't want to bug >him/her by sending another message, but I do want to know when the >original >call fires.
Why can't you have the callbacks attached to the deferred, share a flag?
if flag == False:
flag = True
# do body of function
# don't do anything - flag have been previously fired
If I understand what is happening, this should work because of the non-preemptive nature of the reactor, that is you ought not get a race
More information about the Twisted-Python