Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
532c9290
Commit
532c9290
authored
Aug 29, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monkey: do patch create_connection; add a comment why
parent
e8089cb1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
6 deletions
+9
-6
gevent/monkey.py
gevent/monkey.py
+9
-6
No files found.
gevent/monkey.py
View file @
532c9290
...
...
@@ -135,12 +135,15 @@ def patch_socket(dns=True, aggressive=True):
If *dns* is true, also patch dns functions in :mod:`socket`.
"""
from
gevent
import
socket
items
=
socket
.
__implements__
[:]
if
not
dns
:
for
function
in
socket
.
__dns__
:
items
.
remove
(
function
)
# if we patch socket.socket then create_connection is already good
items
.
remove
(
'create_connection'
)
# Note: although it seems like it's not strictly necessary to monkey patch 'create_connection',
# it's better to do it. If 'create_connection' was not monkey patched, but the rest of socket module
# was, create_connection would still use "green" getaddrinfo and "green" socket.
# However, because gevent.socket.socket.connect is a Python function, the exception raised by it causes
# _socket object to be referenced by the frame, thus causing the next invocation of bind(source_address) to fail.
if
dns
:
items
=
socket
.
__implements__
else
:
items
=
set
(
socket
.
__implements__
)
-
set
(
socket
.
__dns__
)
patch_module
(
'socket'
,
items
=
items
)
if
aggressive
:
if
'ssl'
not
in
socket
.
__implements__
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment