Skip to content

Conversation

@vstinner
Copy link
Contributor

@vstinner vstinner commented Mar 6, 2015

This change fixes the threading support on Python 3.4 when eventlet is used with monkey-patching.

Python 3.4 introduces threading.Thread._tstate_lock to fix a race condition, see:

I'm not really proud of this change: patching a Thread instance after its creation is not the most elegant fix.

I tried to create a Thread subclass in eventlet.green.threading, but I got a lot of new issues. If the subclass is declared in eventlet.green.threading, the parent Thread class uses functions of the original threading module, instead of using patched functions by eventlet. It's unclear to me how symbols are added and patched in modules. I noticed that the threading module of the standard library is imported multiple times. The implementation of monkey-patching is really complex :-/

Currently, the best solution is to patch Thread instance in the patched thread.start_new_thread() function. The problem is to retrieve the instance. My heuristic checks if the wrapped function is the bounded Thread.run() method, and I retrieve the instance from function.self.

I'm not yet sure that I really understood the problem. At least, "tox -e py34-selects" pass.

vstinner and others added 3 commits March 6, 2015 22:58
For the Python implementation of threading.RLock because the new C
implementation of threading.RLock of Python 3.3 is not compatible with
eventlet monkey patching.

Fix the issue #185.
@vstinner
Copy link
Contributor Author

vstinner commented Mar 6, 2015

Oh, my commit was already pushed to pull request #187, it's not useful to open a duplicate pull request. I'm closing this one.

@vstinner vstinner closed this Mar 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants