Closed vdwees closed 2 years ago
Definitely a bug. I guess self.future
is canceled when we try to set it. Do you have a snippet to reproduce the problem ?
Its not every time, but on my machine if I run this a few times it does show up.
import asyncio
from datetime import timezone
import aiocron
async def wait_for():
try:
await aiocron.crontab("* * * * * */1", tz=timezone.utc).next()
except asyncio.CancelledError:
print("cancelled")
else:
print("done")
async def main():
task = asyncio.create_task(wait_for())
await asyncio.sleep(0.5)
task.cancel()
await task
await asyncio.sleep(1.0)
asyncio.run(main())
I've added an explicit call to stop() on receiving the cancelled error, which seems like a reasonable workaround.
When I cancel an asyncio.Task that is awaiting an aiocron next(), sometimes I see this error. Any ideas?