A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2007-October/075030.html below:

[Python-Dev] Deadlock by a second import in a thread

[Python-Dev] Deadlock by a second import in a threadFacundo Batista facundobatista at gmail.com
Fri Oct 26 04:34:56 CEST 2007
2007/10/20, Nick Coghlan <ncoghlan at gmail.com>:

> bb.py is broken - importing a module should never spawn a new thread as
> a side effect (precisely because it will deadlock if the spawned thread
> tries to do an import, which can happen in a myriad of ways).

Exactly, :(.

I changed timeobject.c to import _strptime once at init time. But the
problem still happened, because the function strptime needs to parse
the format, and this involves a regex sub() call, which finish in a
pattern_subx() call in _srec.c, which needs to call to _subx() in the
re module through the call() function, which finally issues another
import, creating the deadlock again.

In short: you can not avoid a second import unless you rewrite *a lot*
of internal code.

BTW, I'll leave the optimization of importing strptime one time,
there's no reason to try to import it everytime strptime() is called.

Regards,

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4