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
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to