gawel / aiocron

Crontabs for asyncio
MIT License
338 stars 20 forks source link

The library is not working with Python 3.10 (removed loop as a parameter to most asyncio functions) #22

Closed tamaroth closed 2 years ago

tamaroth commented 2 years ago

Python 3.10 has removed the loop parameter from most of its functions (it was deprecated since Python 3.8). As a result it is currently impossible to use the library with the newest Python version.

gawel commented 2 years ago

Can you add a traceback or something ? Doesn't looks like aiocron is using the high level api

tamaroth commented 2 years ago

Sure, should have added it right away:

2021-11-19 12:16:44.002374 [error    ] Exception in callback None()
handle: <TimerHandle cancelled when=140694.05696083547> [asyncio] 
Traceback (most recent call last):
  File "/home/tamaroth/.pyenv/versions/3.10.0/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/Work/repos/cim/virtualenv/lib/python3.10/site-packages/aiocron/__init__.py", line 80, in call_next
    self.call_func()
  File "/Work/repos/cim/virtualenv/lib/python3.10/site-packages/aiocron/__init__.py", line 84, in call_func
    asyncio.gather(
TypeError: gather() got an unexpected keyword argument 'loop'

This is described also here:

Deprecated since version 3.8, removed in version 3.10: The loop parameter. This function has been implicitly getting the current running loop since 3.7. See What’s New in 3.10’s Removed section for more information.

I have manually commented out the loop parameter here so it works for me locally. Obviously this is not a solution for the library itself. It'd be easier if you were to support only Python 3.7+, but otherwise I suppose you will have to do some version detection magic.

gawel commented 2 years ago

Or avoid using gather which seems to be the only problem. Got it. Thanks