[Twisted-Python] DeferredSemaphore - action on acquire and release

Stephen Thorne stephen at thorne.id.au
Mon Feb 7 22:46:20 EST 2011


On 2011-02-08, Jason Heeris wrote:
> On 8 February 2011 10:45, Jason Rennie <jrennie at gmail.com> wrote:
> > I think what you have duplicating functionality---you're not taking
> > advantage of the DeferredSemaphore.
> 
> I thought using the "run" method *was* the preferred way to use a DS,
> but whatever works.
> >
> > Shouldn't this be spelled:
> >
> > d = sem.run(doSerialStuff)
> >
> > Which does acquasition and release of the sempahore properly?
> 
> Won't you then be trying to acquire or release it twice?

Um, that's what I mean, you shouldn't be using .acquire() or .release(),
just .run(). doSerialStuff doesn't need a reference to the semaphore
object.

-- 
Regards,
Stephen Thorne
Development Engineer
Netbox Blue



More information about the Twisted-Python mailing list