multithreading

Kiuhnm kiuhnm03.4t.yahoo.it
Sat Apr 7 10:35:20 EDT 2012


I'm about to write my first module and I don't know how I should handle 
multithreading/-processing.
I'm not doing multi-threading inside my module. I'm just trying to make 
it thread-safe so that users *can* do multi-threading.

For instance, let's say I want to make this code thread-safe:

--->
myDict = {}

def f(name, val):
     if name not in myDict:
         myDict[name] = val
     return myDict[name]
<---

I could use threading.Lock() but I don't know if that might interfere 
with some other modules imported by the user.
In some languages you can't mix multi-threading libraries. Is Python one 
of them?

Kiuhnm



More information about the Python-list mailing list