how to make a function thread-safe ?

Aahz Maruch aahz at panix.com
Fri Mar 9 17:24:55 EST 2001


In article <3AA94A6A.50138001 at noaa.gov>,
j vickroy  <jim.vickroy at noaa.gov> wrote:
>
>If a function may be applied (simultaneously) by multiple threads is the
>safe (correct) procedure to wrap the function inside a class and have
>each thread create its own instance of the class?

As long as the function uses strictly local data, there's no need to do
any wrapping or locking, just as it's safe to use functions from the
string module.  If the function uses shared data, things get a lot more
complicated, and you'll need to give us more info if you want advice.
-- 
                      --- Aahz (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

"..., and some of you may regard all women as evil traps that exist only
to tease, torture, and suck out your very soul."  --DrMax



More information about the Python-list mailing list