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
9c6ba97c
Commit
9c6ba97c
authored
Jun 25, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update documentation for wait/iwait. Update changelog.
parent
c9db4115
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
16 deletions
+31
-16
changelog.rst
changelog.rst
+4
-1
gevent/hub.py
gevent/hub.py
+27
-15
No files found.
changelog.rst
View file @
9c6ba97c
...
...
@@ -7,13 +7,16 @@ Changelog
Unreleased
----------
- Fix LifoQueue.peek() to return correct element. PR #456. Patch by Christine Spang.
- Add support for Python 3.3 and 3.4.
- Add support for PyPy.
- Fix gevent.greenlet.joinall to not ignore ``count`` when
``raise_error`` is False. PR #512 by Ivan Diao.
- Fix subprocess.Popen to not ignore the ``bufsize`` argument. Note
that this changes the (platform dependent) default, typically from
buffered to unbuffered. PR #542 by Romuald Brunet.
- Upgraded c-ares to 1.10.0. PR #579 by Omer Katz.
- Add a ``count`` argument to ``gevent.greenlet.wait``. PR #482 by
wiggin15.
Release 1.0.2
-------------
...
...
gevent/hub.py
View file @
9c6ba97c
...
...
@@ -606,26 +606,32 @@ class Waiter(object):
def
iwait
(
objects
,
timeout
=
None
,
count
=
None
):
"""Yield objects as they are ready, until all are ready or timeout expired.
"""
Yield objects as they are ready, until all (or `count`) are ready or `timeout` expired.
*objects* must be iterable yielding instance implementing wait protocol (rawlink() and unlink()).
:param objects: A list (supporting `len`) containing objects
implementing the wait protocol (rawlink() and unlink()).
:param count: If not `None`, then a number specifying the maximum number
of objects to wait for.
"""
# QQQ would be nice to support iterable here that can be generated slowly (why?)
if
objects
is
None
:
yield
get_hub
().
join
(
timeout
=
timeout
)
return
waiter
=
Waiter
()
switch
=
waiter
.
switch
if
timeout
is
not
None
:
timer
=
get_hub
().
loop
.
timer
(
timeout
,
priority
=-
1
)
timer
.
start
(
waiter
.
switch
,
_NONE
)
count
=
len
(
objects
)
if
count
is
None
else
min
(
count
,
len
(
objects
))
try
:
if
count
is
None
:
count
=
len
(
objects
)
else
:
count
=
min
(
count
,
len
(
objects
))
for
obj
in
objects
:
obj
.
rawlink
(
switch
)
for
_
in
xrange
(
count
):
item
=
waiter
.
get
()
waiter
.
clear
()
...
...
@@ -645,30 +651,36 @@ def iwait(objects, timeout=None, count=None):
def
wait
(
objects
=
None
,
timeout
=
None
,
count
=
None
):
"""Wait for *objects* to become ready or for event loop to finish.
"""
Wait for ``objects`` to become ready or for event loop to finish.
If
*objects* is provided, it should be an iterable containg objects implementing wait protocol (rawlink() and
unlink() methods):
If
``objects`` is provided, it must be an list containing objects
implementing the wait protocol (rawlink() and
unlink() methods):
- :class:`gevent.Greenlet` instance
- :class:`gevent.event.Event` instance
- :class:`gevent.lock.Semaphore` instance
- :class:`gevent.subprocess.Popen` instance
If *objects* is ``None`` (the default), ``wait()`` blocks until all event loops has nothing to do:
If ``objects`` is ``None`` (the default), ``wait()`` blocks until
all event loops have nothing to do (or until ``timeout`` passes):
- all greenlets have finished
- all servers were stopped
- all event loop watchers were stopped.
If *count* is ``None`` (the default), wait for all of *object* to become ready.
If ``count`` is ``None`` (the default), wait for all ``object``s
to become ready.
If *count* is a number, wait for *count* object to become ready. (For example, if count is ``1`` then the
function exits when any object in the list is ready).
If ``count`` is a number, wait for (up to) ``count`` objects to become
ready. (For example, if count is ``1`` then the function exits
when any object in the list is ready).
If *timeout* is provided, it specifies the maximum number of seconds ``wait()`` will block.
If ``timeout`` is provided, it specifies the maximum number of
seconds ``wait()`` will block.
Returns the list of ready objects, in the order in which they were ready.
Returns the list of ready objects, in the order in which they were
ready.
"""
if
objects
is
None
:
return
get_hub
().
join
(
timeout
=
timeout
)
...
...
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