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

Conversation

Projects
None yet
2 participants
@vstinner
Contributor

vstinner commented Apr 20, 2015

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

Issue #230: Fix patcher.original()
Don't load a module twice when eventlet monkey-patched is not used.
@temoto

This comment has been minimized.

Show comment
Hide comment
@temoto

temoto Apr 20, 2015

Member

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]
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.

Show comment
Hide comment
@temoto

temoto Apr 20, 2015

Member

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

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.

Show comment
Hide comment
@vstinner

vstinner Apr 20, 2015

Contributor

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
Contributor

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.

Show comment
Hide comment
@temoto

temoto Apr 20, 2015

Member

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?

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 modified the milestones: v0.20, v0.19 May 2, 2016

@vstinner

This comment has been minimized.

Show comment
Hide comment
@vstinner

vstinner Dec 5, 2016

Contributor

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

Contributor

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