Hi Terry:

--- On Thu, 4/23/09, twisted-python-requ...@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?

global flag

def callback(....):
    global flag
    if flag == False:
       flag = True
       # do body of function
    else:
       # 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
condition.

Cheers,
Andrew






      

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to