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
d879e664
Commit
d879e664
authored
Jun 07, 2011
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test case for pool.imap
parent
8fe8a9b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
0 deletions
+15
-0
greentest/test__pool.py
greentest/test__pool.py
+15
-0
No files found.
greentest/test__pool.py
View file @
d879e664
...
...
@@ -3,6 +3,7 @@ import gevent
from
gevent
import
pool
from
gevent.event
import
Event
import
greentest
import
random
class
TestCoroutinePool
(
greentest
.
TestCase
):
...
...
@@ -182,6 +183,12 @@ def sqr(x, wait=0.0):
gevent
.
sleep
(
wait
)
return
x
*
x
def
sqr_random_sleep
(
x
):
gevent
.
sleep
(
random
.
random
()
*
0.1
)
return
x
*
x
TIMEOUT1
,
TIMEOUT2
,
TIMEOUT3
=
0.082
,
0.035
,
0.14
...
...
@@ -242,6 +249,10 @@ class TestPool(greentest.TestCase):
self
.
assertEqual
(
it
.
next
(),
i
*
i
)
self
.
assertRaises
(
StopIteration
,
it
.
next
)
def
test_imap_random
(
self
):
it
=
self
.
pool
.
imap
(
sqr_random_sleep
,
range
(
10
))
self
.
assertEqual
(
list
(
it
),
map
(
sqr
,
range
(
10
)))
def
test_imap_unordered
(
self
):
it
=
self
.
pool
.
imap_unordered
(
sqr
,
range
(
1000
))
self
.
assertEqual
(
sorted
(
it
),
map
(
sqr
,
range
(
1000
)))
...
...
@@ -249,6 +260,10 @@ class TestPool(greentest.TestCase):
it
=
self
.
pool
.
imap_unordered
(
sqr
,
range
(
1000
))
self
.
assertEqual
(
sorted
(
it
),
map
(
sqr
,
range
(
1000
)))
def
test_imap_unordered_random
(
self
):
it
=
self
.
pool
.
imap_unordered
(
sqr_random_sleep
,
range
(
10
))
self
.
assertEqual
(
sorted
(
it
),
map
(
sqr
,
range
(
10
)))
def
test_terminate
(
self
):
result
=
self
.
pool
.
map_async
(
gevent
.
sleep
,
[
0.1
]
*
((
self
.
size
or
10
)
*
2
))
gevent
.
sleep
(
0.1
)
...
...
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