Re: Synchronization methodology
- From: Duncan Booth <duncan.booth@xxxxxxxxxxxxxxx>
- Date: 3 Jan 2007 11:09:00 GMT
Marc 'BlackJack' Rintsch <bj_666@xxxxxxx> wrote:
You may want to make sure the lock will be released in case of an
exception:
def foo(self):
self.lock.aquire()
try:
pass # code
finally:
self.lock.release()
In Python 2.5 this can also be written more succintly using the with
statement so foo becomes:
from __future__ import with_statement
....
def foo(self):
with self.lock:
pass # insert your code here
or write a decorator.
.
- References:
- Synchronization methodology
- From: Chris Ashurst
- Re: Synchronization methodology
- From: Marc 'BlackJack' Rintsch
- Synchronization methodology
- Prev by Date: Re: Synchronization methodology
- Next by Date: Re: import order or cross import
- Previous by thread: Re: Synchronization methodology
- Next by thread: Re: Synchronization methodology
- Index(es):
Relevant Pages
|