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
e2c6fbba
Commit
e2c6fbba
authored
Aug 01, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for shutdown()
parent
30cd8f0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
greentest/test__hub.py
greentest/test__hub.py
+37
-0
No files found.
greentest/test__hub.py
View file @
e2c6fbba
...
...
@@ -20,6 +20,7 @@
# THE SOFTWARE.
import
greentest
import
unittest
import
time
import
gevent
from
gevent
import
core
...
...
@@ -78,6 +79,42 @@ class TestExceptionInMainloop(greentest.TestCase):
assert
delay
>=
DELAY
*
0.9
,
'sleep returned after %s seconds (was scheduled for %s)'
%
(
delay
,
DELAY
)
class
TestShutdown
(
unittest
.
TestCase
):
def
_shutdown
(
self
,
seconds
=
0
,
fuzzy
=
0.01
):
start
=
time
.
time
()
gevent
.
greenlet
.
shutdown
()
delta
=
time
.
time
()
-
start
assert
seconds
-
fuzzy
<
delta
<
seconds
+
fuzzy
,
(
seconds
-
fuzzy
,
delta
,
seconds
+
fuzzy
)
def
assert_hub
(
self
):
assert
'hub'
in
gevent
.
greenlet
.
_threadlocal
.
__dict__
def
assert_no_hub
(
self
):
assert
'hub'
not
in
gevent
.
greenlet
.
_threadlocal
.
__dict__
def
test
(
self
):
assert
not
gevent
.
greenlet
.
get_hub
().
dead
self
.
_shutdown
()
self
.
assert_no_hub
()
# shutting down dead hub is silent
self
.
_shutdown
()
self
.
_shutdown
()
self
.
assert_no_hub
()
# ressurect
gevent
.
sleep
(
0
)
self
.
assert_hub
()
gevent
.
core
.
timer
(
0.1
,
lambda
:
None
)
self
.
assert_hub
()
self
.
_shutdown
(
seconds
=
0.1
)
self
.
assert_no_hub
()
self
.
_shutdown
(
seconds
=
0
)
self
.
assert_no_hub
()
if
__name__
==
'__main__'
:
greentest
.
main
()
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