Replace gen.multi(futures) with asyncio.gather(*futures)

This commit is contained in:
Erik Sundell
2020-11-06 06:41:29 +01:00
parent 4a17441e5a
commit 77ed2faf31
3 changed files with 4 additions and 6 deletions

View File

@@ -2120,7 +2120,7 @@ class JupyterHub(Application):
self.log.debug( self.log.debug(
"Awaiting checks for %i possibly-running spawners", len(check_futures) "Awaiting checks for %i possibly-running spawners", len(check_futures)
) )
await gen.multi(check_futures) await asyncio.gather(*check_futures)
db.commit() db.commit()
# only perform this query if we are going to log it # only perform this query if we are going to log it

View File

@@ -25,7 +25,6 @@ from functools import wraps
from subprocess import Popen from subprocess import Popen
from urllib.parse import quote from urllib.parse import quote
from tornado import gen
from tornado.httpclient import AsyncHTTPClient from tornado.httpclient import AsyncHTTPClient
from tornado.httpclient import HTTPError from tornado.httpclient import HTTPError
from tornado.httpclient import HTTPRequest from tornado.httpclient import HTTPRequest
@@ -292,7 +291,7 @@ class Proxy(LoggingConfigurable):
if service.server: if service.server:
futures.append(self.add_service(service)) futures.append(self.add_service(service))
# wait after submitting them all # wait after submitting them all
await gen.multi(futures) await asyncio.gather(*futures)
async def add_all_users(self, user_dict): async def add_all_users(self, user_dict):
"""Update the proxy table from the database. """Update the proxy table from the database.
@@ -305,7 +304,7 @@ class Proxy(LoggingConfigurable):
if spawner.ready: if spawner.ready:
futures.append(self.add_user(user, name)) futures.append(self.add_user(user, name))
# wait after submitting them all # wait after submitting them all
await gen.multi(futures) await asyncio.gather(*futures)
@_one_at_a_time @_one_at_a_time
async def check_routes(self, user_dict, service_dict, routes=None): async def check_routes(self, user_dict, service_dict, routes=None):
@@ -391,7 +390,7 @@ class Proxy(LoggingConfigurable):
self.log.warning("Deleting stale route %s", routespec) self.log.warning("Deleting stale route %s", routespec)
futures.append(self.delete_route(routespec)) futures.append(self.delete_route(routespec))
await gen.multi(futures) await asyncio.gather(*futures)
stop = time.perf_counter() # timer stops here when user is deleted stop = time.perf_counter() # timer stops here when user is deleted
CHECK_ROUTES_DURATION_SECONDS.observe(stop - start) # histogram metric CHECK_ROUTES_DURATION_SECONDS.observe(stop - start) # histogram metric

View File

@@ -13,7 +13,6 @@ from urllib.parse import urlparse
from async_generator import async_generator from async_generator import async_generator
from async_generator import yield_ from async_generator import yield_
from pytest import mark from pytest import mark
from tornado import gen
import jupyterhub import jupyterhub
from .. import orm from .. import orm