logoalt Hacker News

dangistan202611 • today at 12:55 AM • 1 reply • view on HN

Huh. I hate neither async nor systemd. There is nothing wrong with async, but if my code is sync, what am I to do?

Also, the claim made that something is "better modeled as async" is wholly unqualified.


Replies

whilenot-dev • today at 6:56 AM

> if my code is sync, what am I to do?

You'd use asyncio.to_thread[0].

I also don't quite get your complaint... asyncio provides a high-level concurrency primitive with coroutines, and that's a good enough primitive for workflow engines. Even with asyncio you could fork/spawn processes easily with aiomultiprocess[1], if you'd ever want or need to.

What's your use case for having more low-level concurrency primitives (threads/processes) available, having to deal with their synchronization, and running workflows sync?

[0]: https://docs.python.org/3/library/asyncio-task.html#asyncio....

[1]: https://aiomultiprocess.omnilib.dev/en/stable/

➕ show 1 reply