gawel / aiocron

Crontabs for asyncio
MIT License
343 stars 21 forks source link

Fix coroutine detection on partials #20

Closed hlecnt closed 3 years ago

hlecnt commented 3 years ago

This code is not working (Python 3.7):

async def do_dump(job: str):
    ...

crontab(job.cron, func=partial(do_dump, job), start=True)

It leads to a "do_dump() is never awaited" error => due to asyncio.iscoroutinefunction(), it does not consider the partial function as a coroutine. Or maybe is there another way to do ?

I have tested the fix on Python 3.7 only.

This PR is a proposal to support coroutine as functools.partial()