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
df8493be
Commit
df8493be
authored
Nov 01, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pool: proper implementation of imap_unordered
parent
8c903808
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
5 deletions
+35
-5
gevent/pool.py
gevent/pool.py
+35
-5
No files found.
gevent/pool.py
View file @
df8493be
...
...
@@ -190,11 +190,8 @@ class Group(object):
def
imap_unordered
(
self
,
func
,
iterable
):
"""The same as imap() except that the ordering of the results from the
returned iterator should be considered arbitrary.
**TODO**: Fix this.
"""
return
iter
(
self
.
map
(
func
,
iterable
))
returned iterator should be considered in arbitrary order."""
return
IMapUnordered
.
spawn
(
self
.
spawn
,
func
,
iterable
)
def
full
(
self
):
return
False
...
...
@@ -203,6 +200,39 @@ class Group(object):
pass
class
IMapUnordered
(
Greenlet
):
def
__init__
(
self
,
spawn
,
func
,
iterable
):
from
gevent.queue
import
Queue
Greenlet
.
__init__
(
self
)
self
.
spawn
=
spawn
self
.
func
=
func
self
.
iterable
=
iterable
self
.
queue
=
Queue
()
self
.
count
=
0
def
__iter__
(
self
):
return
self
.
queue
def
_run
(
self
):
try
:
func
=
self
.
func
for
item
in
self
.
iterable
:
self
.
count
+=
1
self
.
spawn
(
func
,
item
).
rawlink
(
self
.
_on_result
)
finally
:
self
.
__dict__
.
pop
(
'spawn'
,
None
)
self
.
__dict__
.
pop
(
'func'
,
None
)
self
.
__dict__
.
pop
(
'iterable'
,
None
)
def
_on_result
(
self
,
greenlet
):
self
.
count
-=
1
if
greenlet
.
successful
():
self
.
queue
.
put
(
greenlet
.
value
)
if
self
.
ready
()
and
self
.
count
<=
0
:
self
.
queue
.
put
(
StopIteration
)
def
GreenletSet
(
*
args
,
**
kwargs
):
import
warnings
warnings
.
warn
(
"gevent.pool.GreenletSet was renamed to gevent.pool.Group since version 0.13.0"
,
DeprecationWarning
,
stacklevel
=
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