race/deadlock when creating a multiprocessing.manager instance while importing a module ?

Sebastien Binet binet at cern.ch
Wed Dec 16 16:57:37 EST 2009


hi there,

> On Tuesday 15 December 2009 02:49:00 Dave Angel wrote:
> > Since I don't see any other responses, I'll give my guess, even though
> > I'm not very experienced with the multiprocessing module.
> >
> > It's my understanding that threads may not be created or destroyed
> > during an import.  So you need to find a way to defer the creation till
> > the imports are done.
> 
> yes, I figured this much and I already wrapped my module with a
>  ModuleFacade object which has lazy properties attributes [1].
> this solves the problem of import my module, but if the module importing my
> module is itself being imported, I am back to square one.
> 
> and my module is being used by many people.
> 
> I guess I'd need at least a way to detect that somebody is trying to use
>  the lazy properties of my module facade while an import is "still active".
>  is there such a mechanism ?
digging thru the imp.py module, I devised this simple snippet:
import imp
[...]
  if imp.lock_held():
     raise RuntimeError('some crystal clear error message')

thanks for the help :)

cheers,
sebastien.
-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################



More information about the Python-list mailing list