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
6f9e51fe
Commit
6f9e51fe
authored
Mar 20, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Killing the monitoring thread should restore the greenlet trace function.
parent
fcfc9304
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
7 deletions
+22
-7
src/gevent/hub.py
src/gevent/hub.py
+13
-6
src/greentest/test__hub.py
src/greentest/test__hub.py
+9
-1
No files found.
src/gevent/hub.py
View file @
6f9e51fe
...
...
@@ -468,7 +468,7 @@ class PeriodicMonitoringThread(object):
# The trace function that was previously installed,
# if any.
previous_trace_function
=
staticmethod
(
lambda
_event
,
_args
:
None
)
previous_trace_function
=
None
# The absolute minimum we will sleep, regardless of
# what particular monitoring functions want to say.
...
...
@@ -485,7 +485,7 @@ class PeriodicMonitoringThread(object):
# the trace function is threadlocal
assert
get_thread_ident
()
==
hub
.
thread_ident
prev_trace
=
settrace
(
self
.
greenlet_trace
)
self
.
previous_trace_function
=
prev_trace
or
self
.
previous_trace_function
self
.
previous_trace_function
=
prev_trace
# Create the actual monitoring thread. This is effectively a "daemon"
# thread.
...
...
@@ -500,7 +500,8 @@ class PeriodicMonitoringThread(object):
self
.
_active_greenlet
=
args
[
1
]
else
:
self
.
_active_greenlet
=
None
self
.
previous_trace_function
(
event
,
args
)
if
self
.
previous_trace_function
is
not
None
:
self
.
previous_trace_function
(
event
,
args
)
def
monitoring_functions
(
self
):
# Return a list of tuples: [(function, period)]
...
...
@@ -521,6 +522,8 @@ class PeriodicMonitoringThread(object):
def
kill
(
self
):
# Stop this monitoring thread from running.
self
.
should_run
=
False
# Uninstall our tracing hook
settrace
(
self
.
previous_trace_function
)
def
__call__
(
self
):
# The function that runs in the monitoring thread.
...
...
@@ -539,9 +542,13 @@ class PeriodicMonitoringThread(object):
# Make sure the hub is still around, and still active,
# and keep it around while we are here.
hub
=
self
.
_hub_wref
()
if
hub
and
self
.
should_run
:
for
f
,
_
in
functions
:
f
(
hub
)
if
not
hub
:
self
.
kill
()
if
self
.
should_run
:
for
f
,
period
in
functions
:
if
period
:
f
(
hub
)
except
SystemExit
:
pass
except
:
# pylint:disable=bare-except
...
...
src/greentest/test__hub.py
View file @
6f9e51fe
...
...
@@ -176,12 +176,20 @@ class TestPeriodicMonitoringThread(greentest.TestCase):
before_funs
=
monitor
.
_additional_monitoring_functions
monitor
.
add_monitoring_function
(
monitor_cond
,
0
)
0
.01
)
cond
.
wait
()
cond
.
release
()
monitor
.
_additional_monitoring_functions
=
before_funs
@
greentest
.
ignores_leakcheck
def
test_kill_removes_trace
(
self
):
from
greenlet
import
gettrace
hub
=
get_hub
()
hub
.
start_periodic_monitoring_thread
()
self
.
assertIsNotNone
(
gettrace
())
hub
.
periodic_monitoring_thread
.
kill
()
self
.
assertIsNone
(
gettrace
())
@
greentest
.
ignores_leakcheck
def
test_blocking_this_thread
(
self
):
...
...
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