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
97f05b3f
Commit
97f05b3f
authored
Sep 10, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monkey: customize patching dns with 'dns' keyword argument to patch_socket and patch_all
parent
50d2c219
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
gevent/monkey.py
gevent/monkey.py
+11
-5
No files found.
gevent/monkey.py
View file @
97f05b3f
...
...
@@ -24,14 +24,19 @@ def patch_thread():
thread
.
stack_size
=
green_thread
.
stack_size
# XXX should also patch threadlocal
def
patch_socket
():
from
gevent.socket
import
GreenSocket
,
fromfd
,
wrap_ssl
,
socketpair
,
getaddrinfo
,
getnameinfo
,
gethostbyname
def
patch_socket
(
dns
=
True
):
from
gevent.socket
import
GreenSocket
,
fromfd
,
wrap_ssl
,
socketpair
_socket
=
__import__
(
'socket'
)
_socket
.
socket
=
GreenSocket
_socket
.
fromfd
=
fromfd
_socket
.
ssl
=
wrap_ssl
_socket
.
socketpair
=
socketpair
# dns
if
dns
:
patch_dns
()
def
patch_dns
():
from
gevent.socket
import
getaddrinfo
,
getnameinfo
,
gethostbyname
_socket
=
__import__
(
'socket'
)
_socket
.
getaddrinfo
=
getaddrinfo
_socket
.
getnameinfo
=
getnameinfo
_socket
.
gethostbyname
=
gethostbyname
...
...
@@ -48,7 +53,7 @@ def patch_select():
globals
()[
'_select_select'
]
=
_select
.
select
_select
.
select
=
select
def
patch_all
(
socket
=
True
,
time
=
True
,
select
=
True
,
thread
=
True
,
os
=
True
,
ssl
=
True
):
def
patch_all
(
socket
=
True
,
dns
=
True
,
time
=
True
,
select
=
True
,
thread
=
True
,
os
=
True
,
ssl
=
True
):
# order is important
if
os
:
patch_os
()
...
...
@@ -57,12 +62,13 @@ def patch_all(socket=True, time=True, select=True, thread=True, os=True, ssl=Tru
if
thread
:
patch_thread
()
if
socket
:
patch_socket
()
patch_socket
(
dns
=
dns
)
if
select
:
patch_select
()
if
ssl
:
patch_ssl
()
if
__name__
==
'__main__'
:
modules
=
[
x
.
replace
(
'patch_'
,
''
)
for
x
in
globals
().
keys
()
if
x
.
startswith
(
'patch_'
)
and
x
!=
'patch_all'
]
script_help
=
"""gevent.monkey - monkey patch the standard modules to use gevent.
...
...
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