Make a small function thread safe
Brad Tilley
kj4eit at gmail.com
Fri Dec 16 10:05:32 EST 2011
On Dec 16, 9:36 am, Tim Wintle <tim.win... at teamrubber.com> wrote:
> should be:
> def run(t):
> with lock:
> shared_container.append(t.name)
>
> (or lock.acquire() and lock.release() as you mentioned)
Thanks Tim. The with statement is closer to the C++ code (IMO) more so
than the explicit acquire() and release() so I'll use that approach. I
appreciate your advice.
Brad
More information about the Python-list
mailing list