How a module is being marked as imported?

2016-02-04 Thread Jean-Charles Lefebvre
Hi all, The short version: How CPython marks a module as being fully imported, if it does, so that the same import statement ran from another C thread at the same time does not collide? Or, reversely, does not think the module is not already fully imported? The full version: I'm running

Re: How a module is being marked as imported?

2016-02-04 Thread Jean-Charles Lefebvre
So far, I've been advised to: 1/ Double-check that the GIL was correctly acquired 2/ Ensure there's no 'string' module in my project 3/ Manually pre-import commonly used standard modules at interpreter's init-time to avoid race conditions due to the multi-threaded nature of the running

Re: How a module is being marked as imported?

2016-02-04 Thread Kevin Conway
As an attempt to answer your original question, Python doesn't explicitly mark a module as done. It does keep imports cached in sys.modules, though. The behaviour you describe where later imports get the same module object is driven by that cache. There are cases, such as cyclical imports, where