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
4bdcbd50
Commit
4bdcbd50
authored
Dec 12, 2011
by
Ralf Schmitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
py3 fixes for test__pool.py and pool.py
parent
2173ff57
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
gevent/pool.py
gevent/pool.py
+9
-0
greentest/test__pool.py
greentest/test__pool.py
+14
-14
No files found.
gevent/pool.py
View file @
4bdcbd50
...
...
@@ -17,6 +17,7 @@ from gevent.greenlet import joinall, Greenlet
from
gevent.timeout
import
Timeout
from
gevent.event
import
Event
from
gevent.coros
import
Semaphore
,
DummySemaphore
from
gevent
import
six
__all__
=
[
'Group'
,
'Pool'
]
...
...
@@ -228,6 +229,10 @@ class IMapUnordered(Greenlet):
raise
value
.
exc
return
value
if
six
.
PY3
:
__next__
=
next
del
next
def
_run
(
self
):
try
:
func
=
self
.
func
...
...
@@ -284,6 +289,10 @@ class IMap(Greenlet):
raise
value
.
exc
if
value
is
not
_SKIP
:
return
value
if
six
.
PY3
:
__next__
=
next
del
next
def
_run
(
self
):
try
:
...
...
greentest/test__pool.py
View file @
4bdcbd50
from
time
import
time
import
gevent
from
gevent
import
pool
from
gevent
import
pool
,
six
from
gevent.event
import
Event
import
greentest
import
random
...
...
@@ -48,7 +48,7 @@ class TestCoroutinePool(greentest.TestCase):
done
=
pool
.
spawn
(
consumer
)
pool
.
apply_async
(
producer
)
done
.
get
()
self
.
assertEqual
s
([
'cons1'
,
'prod'
,
'cons2'
],
results
)
self
.
assertEqual
([
'cons1'
,
'prod'
,
'cons2'
],
results
)
def
dont_test_timer_cancel
(
self
):
timer_fired
=
[]
...
...
@@ -62,7 +62,7 @@ class TestCoroutinePool(greentest.TestCase):
pool
=
self
.
klass
(
2
)
pool
.
apply
(
some_work
)
gevent
.
sleep
(
0
)
self
.
assertEqual
s
(
timer_fired
,
[])
self
.
assertEqual
(
timer_fired
,
[])
def
test_reentrant
(
self
):
pool
=
self
.
klass
(
1
)
...
...
@@ -211,8 +211,8 @@ class TestPool(greentest.TestCase):
def
test_map
(
self
):
pmap
=
self
.
pool
.
map
self
.
assertEqual
(
pmap
(
sqr
,
range
(
10
)),
map
(
sqr
,
range
(
10
)))
self
.
assertEqual
(
pmap
(
sqr
,
range
(
100
)),
map
(
sqr
,
range
(
100
)))
self
.
assertEqual
(
pmap
(
sqr
,
range
(
10
)),
list
(
map
(
sqr
,
range
(
10
)
)))
self
.
assertEqual
(
pmap
(
sqr
,
range
(
100
)),
list
(
map
(
sqr
,
range
(
100
)
)))
def
test_async
(
self
):
res
=
self
.
pool
.
apply_async
(
sqr
,
(
7
,
TIMEOUT1
,))
...
...
@@ -238,32 +238,32 @@ class TestPool(greentest.TestCase):
def
test_imap
(
self
):
it
=
self
.
pool
.
imap
(
sqr
,
range
(
10
))
self
.
assertEqual
(
list
(
it
),
map
(
sqr
,
range
(
10
)))
self
.
assertEqual
(
list
(
it
),
list
(
map
(
sqr
,
range
(
10
)
)))
it
=
self
.
pool
.
imap
(
sqr
,
range
(
10
))
for
i
in
range
(
10
):
self
.
assertEqual
(
it
.
next
(
),
i
*
i
)
self
.
assertRaises
(
StopIteration
,
it
.
next
)
self
.
assertEqual
(
six
.
advance_iterator
(
it
),
i
*
i
)
self
.
assertRaises
(
StopIteration
,
lambda
:
six
.
advance_iterator
(
it
)
)
it
=
self
.
pool
.
imap
(
sqr
,
range
(
1000
))
for
i
in
range
(
1000
):
self
.
assertEqual
(
it
.
next
(
),
i
*
i
)
self
.
assertRaises
(
StopIteration
,
it
.
next
)
self
.
assertEqual
(
six
.
advance_iterator
(
it
),
i
*
i
)
self
.
assertRaises
(
StopIteration
,
lambda
:
six
.
advance_iterator
(
it
)
)
def
test_imap_random
(
self
):
it
=
self
.
pool
.
imap
(
sqr_random_sleep
,
range
(
10
))
self
.
assertEqual
(
list
(
it
),
map
(
sqr
,
range
(
10
)))
self
.
assertEqual
(
list
(
it
),
list
(
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
)))
self
.
assertEqual
(
sorted
(
it
),
list
(
map
(
sqr
,
range
(
1000
)
)))
it
=
self
.
pool
.
imap_unordered
(
sqr
,
range
(
1000
))
self
.
assertEqual
(
sorted
(
it
),
map
(
sqr
,
range
(
1000
)))
self
.
assertEqual
(
sorted
(
it
),
list
(
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
)))
self
.
assertEqual
(
sorted
(
it
),
list
(
map
(
sqr
,
range
(
10
)
)))
def
test_terminate
(
self
):
result
=
self
.
pool
.
map_async
(
gevent
.
sleep
,
[
0.1
]
*
((
self
.
size
or
10
)
*
2
))
...
...
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