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
a171d819
Commit
a171d819
authored
Jul 21, 2009
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for proc.ProcSet
parent
6f25a2ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
0 deletions
+97
-0
greentest/test__proc_procset.py
greentest/test__proc_procset.py
+97
-0
No files found.
greentest/test__proc_procset.py
0 → 100644
View file @
a171d819
import
time
import
greentest
import
gevent
from
gevent
import
proc
DELAY
=
0.01
class
Undead
(
object
):
def
__init__
(
self
):
self
.
shot_count
=
0
def
__call__
(
self
):
while
True
:
try
:
gevent
.
sleep
(
1
)
except
:
self
.
shot_count
+=
1
class
Test
(
greentest
.
TestCase
):
def
test_basic
(
self
):
DELAY
=
0.05
s
=
proc
.
ProcSet
()
s
.
spawn
(
gevent
.
sleep
,
DELAY
)
s
.
spawn
(
gevent
.
sleep
,
DELAY
*
2.
)
assert
len
(
s
)
==
2
,
s
gevent
.
sleep
(
DELAY
*
3.
/
2.
)
assert
len
(
s
)
==
1
,
s
gevent
.
sleep
(
DELAY
)
assert
not
s
,
s
def
test_waitall
(
self
):
s
=
proc
.
ProcSet
()
s
.
spawn
(
gevent
.
sleep
,
DELAY
)
s
.
spawn
(
gevent
.
sleep
,
DELAY
*
2
)
assert
len
(
s
)
==
2
,
s
start
=
time
.
time
()
s
.
waitall
()
delta
=
time
.
time
()
-
start
assert
not
s
,
s
assert
len
(
s
)
==
0
,
s
assert
DELAY
*
2
<
delta
<
DELAY
*
2.5
,
delta
def
test_killall_wait
(
self
):
s
=
proc
.
ProcSet
()
s
.
spawn
(
gevent
.
sleep
,
DELAY
)
s
.
spawn
(
gevent
.
sleep
,
DELAY
*
2
)
assert
len
(
s
)
==
2
,
s
start
=
time
.
time
()
s
.
killall
(
wait
=
True
)
assert
not
s
,
s
assert
len
(
s
)
==
0
,
s
delta
=
time
.
time
()
-
start
assert
delta
<
DELAY
*
0.5
,
delta
def
test_killall_nowait
(
self
):
s
=
proc
.
ProcSet
()
s
.
spawn
(
gevent
.
sleep
,
DELAY
)
s
.
spawn
(
gevent
.
sleep
,
DELAY
*
2
)
assert
len
(
s
)
==
2
,
s
s
.
killall
()
assert
len
(
s
)
==
2
,
s
gevent
.
sleep
(
0
)
assert
not
s
,
s
assert
len
(
s
)
==
0
,
s
def
test_kill_fires_once
(
self
):
u1
=
Undead
()
u2
=
Undead
()
p1
=
proc
.
spawn
(
u1
)
p2
=
proc
.
spawn
(
u2
)
s
=
proc
.
ProcSet
([
p1
,
p2
])
assert
u1
.
shot_count
==
0
,
u1
.
shot_count
s
.
kill
(
p1
)
assert
u1
.
shot_count
==
0
,
u1
.
shot_count
gevent
.
sleep
(
0
)
assert
u1
.
shot_count
==
1
,
u1
.
shot_count
s
.
kill
(
p1
)
assert
u1
.
shot_count
==
1
,
u1
.
shot_count
s
.
kill
(
p1
)
assert
u2
.
shot_count
==
0
,
u2
.
shot_count
s
.
killall
()
s
.
killall
()
s
.
killall
()
assert
u1
.
shot_count
==
1
,
u1
.
shot_count
assert
u2
.
shot_count
==
0
,
u2
.
shot_count
gevent
.
sleep
(
DELAY
)
assert
u1
.
shot_count
==
1
,
u1
.
shot_count
assert
u2
.
shot_count
==
1
,
u2
.
shot_count
X
=
object
()
assert
X
is
gevent
.
with_timeout
(
DELAY
,
s
.
killall
,
wait
=
True
,
timeout_value
=
X
)
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