Dramatiq

AsyncIO middleware incompatible with multiple threads

critical
configurationUpdated Sep 13, 2023(via Exa)
Technologies:
How to detect:

When using the AsyncIO middleware with Dramatiq 1.15+ and Python 3.11, workers hang if configured with multiple threads. The AsyncIO event loop is not thread-safe and causes deadlocks or hangs when accessed concurrently.

Recommended action:

When using the AsyncIO middleware, configure workers with --processes 1 --threads 1 to ensure single-threaded execution. If higher concurrency is needed, increase the number of processes instead of threads, as each process gets its own event loop.