procrastinate-org / procrastinate

PostgreSQL-based Task Queue for Python
https://procrastinate.readthedocs.io/
MIT License
867 stars 54 forks source link

Drop support for Python v3.8 and remove asgiref from non Django code #1222

Open medihack opened 1 month ago

medihack commented 1 month ago

As discussed on Discord, we want to drop support for Python v3.8 as it reached its end-of-life. We then can use asyncio.to_thread (available in Python >= 3.9) instead of asgiref.sync.sync_to_async (we should then do this together in the 3.0 release).

medihack commented 1 month ago

I took a quick look at replacing asgiref.sync_to_async with asyncio.to_thread, but I don't think it is worth it. We use sync_to_async quite often as a decorator, which is not directly possible with asyncio.to_thread. And asgiref also has the convenient method the other way around (async_to_sync).

onlyann commented 1 month ago

I think it is more nuanced than that.

asgiref might need to stay for the Django integration as per their async doc.

However, there is no need to make it a dependency for any consumer that is not using Django.

We use sync_to_async quite often as a decorator, which is not directly possible with asyncio.to_thread

That should be fine. Beside Django integration, it seems it is only used in tests. That could stay there or it would be trivial to update to not use a decorator and explicitly wrap the function.

medihack commented 1 month ago

Ok, good point. I will give it a try.

ewjoachim commented 4 weeks ago

So shall I close this as #1224 was merged or do we keep it open for the replacement of sync_to_async ?

medihack commented 4 weeks ago

So shall I close this as #1224 was merged or do we keep it open for the replacement of sync_to_async ?

PR #1226 will close it :-)