[Python-Dev] Dealing with import lock deadlock in Import Hooks

Antoine Pitrou solipsis at pitrou.net
Tue Aug 13 17:31:47 CEST 2013


Le Tue, 13 Aug 2013 17:28:42 +0900,
Arnaud Fontaine <arnaud.fontaine at nexedi.com> a écrit :
> Antoine Pitrou <solipsis at pitrou.net> writes:
> > On Tue, 13 Aug 2013 11:06:51 +0900 Arnaud Fontaine
> > <arnaud.fontaine at nexedi.com> wrote:
> >> I suggested the same in my initial email, but I was wondering if
> >> there could be any issue by releasing the lock in
> >> find_module()/load_module() until the module is actually added to
> >> sys.modules.
> >
> > Well, you are obviously on your own with such hacks. There is a
> > reason the lock exists.
> 
> Yes. Actually, I was thinking about implementing something similar to
> what has been done in Python 3.3 but for Python 2.7 with a
> corser-grain lock. From my understanding of import.c, it should work
> but I was hoping that someone with more experience in import code
> would confirm:

It's probably possible, but it will be non-trivial and delicate to get
right.

> Also, if a patch backporting the features from Python 3.3 to import.c
> for Python 2.7 would be written, is there any chance it could be
> accepted?

Definitely not. We generally don't backport any features, especially
when the risk is high due to a feature's implementation complexity.

Regards

Antoine.




More information about the Python-Dev mailing list