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
394dc70f
Commit
394dc70f
authored
Mar 09, 2018
by
Jason Madden
Committed by
GitHub
Mar 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1137 from gevent/issue1136
Also monkey-patch threading._Event on Python 2. Fixes #1136
parents
c4e2fdb8
24c9b94f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
3 deletions
+15
-3
CHANGES.rst
CHANGES.rst
+4
-0
src/gevent/monkey.py
src/gevent/monkey.py
+5
-0
src/greentest/test__monkey.py
src/greentest/test__monkey.py
+6
-3
No files found.
CHANGES.rst
View file @
394dc70f
...
...
@@ -10,6 +10,10 @@
- Use strongly typed watcher callbacks in the libuv CFFI extensions.
This prevents dozens of compiler warnings.
- On Python 2, when monkey-patching `threading.Event`, also
monkey-patch the underlying class, ``threading._Event``. Some code
may be type-checking for that. See :issue:`1136`.
1.3a2 (2018-03-06)
==================
...
...
src/gevent/monkey.py
View file @
394dc70f
...
...
@@ -405,6 +405,11 @@ def patch_thread(threading=True, _threading_local=True, Event=True, logging=True
if
Event
:
from
gevent.event
import
Event
patch_item
(
threading_mod
,
'Event'
,
Event
)
# Python 2 had `Event` as a function returning
# the private class `_Event`. Some code may be relying
# on that.
if
hasattr
(
threading_mod
,
'_Event'
):
patch_item
(
threading_mod
,
'_Event'
,
Event
)
if
existing_locks
:
_patch_existing_locks
(
threading_mod
)
...
...
src/greentest/test__monkey.py
View file @
394dc70f
...
...
@@ -26,12 +26,15 @@ class TestMonkey(unittest.TestCase):
self
.
assertIs
(
thread
.
start_new_thread
,
gthread
.
start_new_thread
)
self
.
assertIs
(
threading
.
_start_new_thread
,
gthread
.
start_new_thread
)
# Event patched by default
self
.
assertTrue
(
monkey
.
is_object_patched
(
'threading'
,
'Event'
))
if
sys
.
version_info
[
0
]
==
2
:
from
gevent
import
threading
as
gthreading
from
gevent.event
import
Event
as
GEvent
self
.
assertIs
(
threading
.
_sleep
,
gthreading
.
_sleep
)
# Event patched by default
self
.
assertTrue
(
monkey
.
is_object_patched
(
'threading'
,
'Event'
))
self
.
assertTrue
(
monkey
.
is_object_patched
(
'threading'
,
'_Event'
))
self
.
assertIs
(
threading
.
_Event
,
GEvent
)
def
test_socket
(
self
):
import
socket
...
...
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