Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
71a6b9e3
Commit
71a6b9e3
authored
Feb 15, 2018
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
master: Select.all() sugar
parent
4aacf2da
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
docs/api.rst
docs/api.rst
+28
-0
mitogen/master.py
mitogen/master.py
+4
-0
No files found.
docs/api.rst
View file @
71a6b9e3
...
...
@@ -117,6 +117,34 @@ contexts.
for msg in mitogen.master.Select(selects):
print msg.unpickle()
.. py:classmethod:: all (it)
Take an iterable of receivers and retrieve a :py:class:`Message` from
each, returning the result of calling `msg.unpickle()` on each in turn.
Results are returned in the order they arrived.
This is sugar for handling batch :py:class:`Context.call_async`
invocations:
.. code-block:: python
print('Total disk usage: %.02fMiB' % (sum(
mitogen.master.Select.all(
context.call_async(get_disk_usage)
for context in contexts
) / 1048576.0
),))
However, unlike in a naive comprehension such as:
.. code-block:: python
sum(context.call_async(get_disk_usage).get().unpickle()
for context in contexts)
Result processing happens concurrently to new results arriving, so
:py:meth:`all` should always be faster.
.. py:method:: get (timeout=None)
Fetch the next available value from any receiver, or raise
...
...
mitogen/master.py
View file @
71a6b9e3
...
...
@@ -123,6 +123,10 @@ class SelectError(mitogen.core.Error):
class
Select
(
object
):
notify
=
None
@
classmethod
def
all
(
cls
,
receivers
):
return
list
(
msg
.
unpickle
()
for
msg
in
cls
(
receivers
))
def
__init__
(
self
,
receivers
=
(),
oneshot
=
True
):
self
.
_receivers
=
[]
self
.
_oneshot
=
oneshot
...
...
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