On 01:14 pm, jren...@gmail.com wrote:
>Sorry, I don't think I understand the example either---looks to me like
>you're reimplementing a semaphore.  Stephen's right about run().

It sounds like (the other) Jason would be happy with run, except he also 
wants to do something extra each time the lock/semaphore is taken and 
released.  DeferredSemaphore (and the other similar classes) don't 
really offer this functionality.  You just have to work that logic into 
the function you run.  It's possible something like this would be nicer 
than reimplementing the acquire/release logic:

    def run(sem, f):
        def before():
            doAcquire()
            return f()
        d = sem.run(before)
        def after(passthrough):
            doRelease()
            return passthrough
        d.addBoth(after)
        return d

Jean-Paul

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

Reply via email to