hug
hug copied to clipboard
TypeError: gather() got an unexpected keyword argument 'loop'
When I build with python 3.10.2, I get following error:
[ 12s] _________________________________ test_startup _________________________________
[ 12s]
[ 12s] hug_api = <tests.fixtures.TestAPI object at 0x7f51ac4d82c0>
[ 12s]
[ 12s] def test_startup(hug_api):
[ 12s] """Test to ensure hug startup decorators work as expected"""
[ 12s] happened_on_startup = []
[ 12s]
[ 12s] @hug.startup(api=hug_api)
[ 12s] def happens_on_startup(api):
[ 12s] happened_on_startup.append("non-async")
[ 12s]
[ 12s] @hug.startup(api=hug_api)
[ 12s] @asyncio.coroutine
[ 12s] def async_happens_on_startup(api):
[ 12s] happened_on_startup.append("async")
[ 12s]
[ 12s] assert happens_on_startup in hug_api.startup_handlers
[ 12s] assert async_happens_on_startup in hug_api.startup_handlers
[ 12s]
[ 12s] > hug_api._ensure_started()
[ 12s]
[ 12s] tests/test_decorators.py:1596:
[ 12s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 12s]
[ 12s] self = <tests.fixtures.TestAPI object at 0x7f51ac4d82c0>
[ 12s]
[ 12s] def _ensure_started(self):
[ 12s] """Marks the API as started and runs all startup handlers"""
[ 12s] if not self.started:
[ 12s] async_handlers = [
[ 12s] startup_handler
[ 12s] for startup_handler in self.startup_handlers
[ 12s] if introspect.is_coroutine(startup_handler)
[ 12s] ]
[ 12s] if async_handlers:
[ 12s] loop = asyncio.get_event_loop()
[ 12s] loop.run_until_complete(
[ 12s] > asyncio.gather(*[handler(self) for handler in async_handlers], loop=loop)
[ 12s] )
[ 12s] E TypeError: gather() got an unexpected keyword argument 'loop'
[ 12s]
[ 12s] hug/api.py:634: TypeError
Getting the same error when using an async startup function.
It looks like gather doesn't accept a loop argument within asyncio since Python 3.10.
Fixed in #918