diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-03-16 15:34:59 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-03-16 15:34:59 +0000 |
commit | c14c890bf3bdf51352482bbcf09c9300f0e91cc3 (patch) | |
tree | f09a735d06af99739e3b5e457977416e51d1d7f9 /synapse/util | |
parent | Clarify environment variable usage when running in Docker (#6181) (diff) | |
parent | Merge pull request #6279 from matrix-org/erikj/federation_server_async_await (diff) | |
download | synapse-c14c890bf3bdf51352482bbcf09c9300f0e91cc3.tar.xz |
Merge pull request #6279 from matrix-org/erikj/federation_server_async_await
* commit 'b4465564c': Don't return coroutines Make concurrently_execute work with async/await Newsfile Port federation_server to async/await
Diffstat (limited to 'synapse/util')
-rw-r--r-- | synapse/util/async_helpers.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/synapse/util/async_helpers.py b/synapse/util/async_helpers.py index 804dbca443..7659eaeb42 100644 --- a/synapse/util/async_helpers.py +++ b/synapse/util/async_helpers.py @@ -138,7 +138,7 @@ def concurrently_execute(func, args, limit): the number of concurrent executions. Args: - func (func): Function to execute, should return a deferred. + func (func): Function to execute, should return a deferred or coroutine. args (list): List of arguments to pass to func, each invocation of func gets a signle argument. limit (int): Maximum number of conccurent executions. @@ -148,11 +148,10 @@ def concurrently_execute(func, args, limit): """ it = iter(args) - @defer.inlineCallbacks - def _concurrently_execute_inner(): + async def _concurrently_execute_inner(): try: while True: - yield func(next(it)) + await maybe_awaitable(func(next(it))) except StopIteration: pass |