hugapi / hug

Embrace the APIs of the future. Hug aims to make developing APIs as simple as possible, but no simpler.
MIT License
6.86k stars 388 forks source link

TypeError: gather() got an unexpected keyword argument 'loop' #902

Closed pgajdos closed 1 year ago

pgajdos commented 2 years ago

When I build with python 3.10.2, I get following error:

[ 12s] _____ teststartup ____ [ 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/testdecorators.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

ogtega commented 2 years ago

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.

wagner-intevation commented 1 year ago

Fixed in #918