Thread-safe atomic operation

Gordon McMillan gmcm at hypernet.com
Tue Apr 11 10:29:11 EDT 2000


Dong-gweon Oh writes:

> Are these statements thread-safe?
> 1. import xxx
> 2. xxx = __import__('xxx')
> 3. reload(xxx)
> 4. dict['xxx'] = sys.modules['xxx']
> 5. dict.has_key('xxx')

Numbers 2 and 4 could be interrupted between evaluation of 
the RHS and assigment to LHS. For #2 that would be of 
concern only if xxx was a global.



- Gordon




More information about the Python-list mailing list