Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix monkey_patch() on Python 3 #168
referenced this pull request
Nov 24, 2014
importlib cannot use eventlet locks because event locks need to import modules.
It looks like the first call the import in the thread calls eventlet.event.Event().acquire() which calls get_hub() which executes (indirectly) "import eventlet.hubs.epolls" which retries to acquire the same event and the loop restarts.
The eventlet.hubs.epolls module is required to setup the hub. In my test, the hub is first setup in a thread, not in the main thread. The problem is that the hub is setup to acquire a lock to import a module, but setup the hub has to import a lock, whereas the hub requires to import a second module.
I guess that calling "get_hub()" in a thread is enough to reproduce the issue.
The importlib modules maintains a dictionary of locks using the thread identifier for the key.
Traceback raises by patcher_test without the fix:
Please, see this modified commit: 539d3b9
If you are happy with new commit, I'll merge it.
The code looks better like, I prefer your version.
I don't remember why I configured ImportInThread as a daemon thread. You may try to drop "daemon = True" and call "server.join()" just before print("ok").
By the way, you may rename the variable "server" to "thread". I probably used the name "server" because initially the code triggering the bug was much more complex. It was a TCP network server if I remember correctly (the idna encoding is used to encode a socket name, or something like that.)