Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #230: Fix patcher.original() #231

Closed
wants to merge 1 commit into from
Closed

Conversation

@vstinner
Copy link
Contributor

vstinner commented Apr 20, 2015

Don't load a module twice when eventlet monkey-patched is not used.

Don't load a module twice when eventlet monkey-patched is not used.
@temoto

This comment has been minimized.

Copy link
Member

temoto commented Apr 20, 2015

Thanks for fix.

Are you ok with this change in all 3 modified files?

@@ -176,7 +176,7 @@ def original(modname):
        return sys.modules.get(original_name)

    if not already_patched and modname in sys.modules:
-       # Issue #230: Don't load a module twice
+       # https://github.com/eventlet/eventlet/issues/230 Don't load a module twice
        # when eventlet monkey-patched is not used
        return sys.modules[modname]
@temoto

This comment has been minimized.

Copy link
Member

temoto commented Apr 20, 2015

It fails on selects hub. Please have a look https://travis-ci.org/eventlet/eventlet/jobs/59281880

@temoto temoto added this to the v0.18 milestone Apr 20, 2015
@vstinner

This comment has been minimized.

Copy link
Contributor Author

vstinner commented Apr 20, 2015

I didn't understand that calling eventlet.monkey_patch() modifies modules already loaded:

import threading
import eventlet
eventlet.monkey_patch()
# threading has been modified

So my patch doesn't seem correct.

Calling eventlet.monkey_patch() in a thread doesn't work. On Python 2, a KeyError is displayed. On Python 3.4, the thread hangs. Example:

import threading

def test():
    import eventlet; eventlet.monkey_patch()

t = threading.Thread(target=test)
t.start()
t.join()

Output on Python 2.7:

Exception KeyError: KeyError(140222136564944,) in <module 'threading' from '/usr/lib64/python2.7/threading.pyc'> ignored
@temoto

This comment has been minimized.

Copy link
Member

temoto commented Apr 20, 2015

Modifying modules, no matter if they were loaded or not, is the whole point of monkey patching. And, yeah, it's a tough issue. Do you have ideas?

@temoto temoto modified the milestones: v0.19, v0.18 Jan 23, 2016
@temoto temoto force-pushed the eventlet:master branch from 2ab31f0 to 67ec999 Mar 1, 2016
@temoto temoto modified the milestones: v0.20, v0.19 May 2, 2016
@vstinner

This comment has been minimized.

Copy link
Contributor Author

vstinner commented Dec 5, 2016

Sorry, I'm not interested to update this old pull request anymore, so I just close it.

@vstinner vstinner closed this Dec 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.