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

socket.create_connection cannot be used as a context manager #430

Closed
miguelgrinberg opened this issue Aug 11, 2017 · 0 comments
Closed

socket.create_connection cannot be used as a context manager #430

miguelgrinberg opened this issue Aug 11, 2017 · 0 comments

Comments

@miguelgrinberg
Copy link
Contributor

miguelgrinberg commented Aug 11, 2017

Consider the following script:

import socket
with socket.create_connection(('google.com', 80)) as s:
    pass

With the regular standard library socket (PY3 only), this works fine. If the library is monkey patched, though, I get the following:

(py36) $ python test.py
Traceback (most recent call last):
  File "test.py", line 6, in <module>
    with socket.create_connection(('google.com', 80)) as s:
AttributeError: __enter__

The green version of socket seems to be missing the context manager __enter__ and __exit__ methods.

miguelgrinberg added a commit to miguelgrinberg/eventlet that referenced this issue Aug 11, 2017
miguelgrinberg added a commit to miguelgrinberg/eventlet that referenced this issue Aug 11, 2017
miguelgrinberg added a commit to miguelgrinberg/eventlet that referenced this issue Aug 12, 2017
temoto pushed a commit that referenced this issue Aug 12, 2017
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

No branches or pull requests

1 participant