In Python2, does it need to wrap imp.find/load_module with imp_acquire/release_lock?

dieter dieter at handshake.de
Wed Feb 28 01:57:48 EST 2018


Xiang Zhang <zhangyangyu0614 at gmail.com> writes:

> Just like the title. It seems to me it is needed from the source code but codes in stdlib all doesn't do that.

The "import" machinery uses locks of its own (to protect "sys.modules").

I assume that "load_module" will use those locks internally.
"find" might be considered to usually see quite a static situation;
should your file system be modified by concurrent threads, it might
be necessary that you use your own locks to protect against this.





More information about the Python-list mailing list