Make a small function thread safe

ting at thsu.org ting at thsu.org
Mon Dec 19 18:56:43 EST 2011


On Dec 16, 8:21 am, Brad Tilley <kj4... at gmail.com> wrote:
> A thread locks the function on entrance and then releases it on exit.
> What is the equivalent way to do this in Python?

I'm not sure if this applies in your case, but much of the time, you
can use thread local storage, rather thread locking, in order to make
your code thread safe. You tend to run into far less bottleneck and
race condition issues by using thread local storage rather than thread
locking, whenever possible.
--
// T.Hsu



More information about the Python-list mailing list