motherofcoconuts / async-dramatiq

Dramatiq with async support
MIT License
9 stars 1 forks source link

What is the relation between this library and the built-in `AsyncIO` middleware #9

Open WillDaSilva opened 9 months ago

WillDaSilva commented 9 months ago

Thanks for making and releasing this project! I'm getting set up with Dramatiq, and use async task functions. Currently I'm using the built-in AsyncIO middleware, which looks like it runs an event loop for each thread. What's the difference between that, and this project? Is it just that the middleware provided by this project uses the same event loop for all threads?

motherofcoconuts commented 9 months ago

We actually both create 1 thread per worker process which runs the event loop. I call it AsyncWorker they call it EventLoopThread (their name is better). We start that thread and its respective event loop on before_worker_boot in our middleware. My middleware is called AsyncMiddleware and theirs is AsyncIO (again their name is better). So functionally there is no real difference here.

So why did i create this repo? Dramatiq recently added in AsyncIO support (late last year) but before then it was unsupported. I created this a few years ago for an internal project and open sourced it last year once i had some spare time.

I would recommend, now that dramatiq has official support, that you use theirs rather then mine :)