I've created a simple script to test dramatiq with redis:
broker_redis = RedisBroker(host='localhost', port=6379)
@dramatiq.actor
def sq(x):
time.sleep(random.randint(2, 4))
return x * x
I'm using this command to run inside WSL (as prescribed by the docs):
dramatiq script_name:broker_redis
It runs without any errors, and it prints out these lines on the console:
[2020-05-06 09:46:28,535] [PID 508] [MainThread] [dramatiq.MainProcess] [INFO] Dramatiq '1.8.1' is booting up.
[2020-05-06 09:46:28,535] [PID 511] [MainThread] [dramatiq.WorkerProcess(1)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,546] [PID 510] [MainThread] [dramatiq.WorkerProcess(0)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,548] [PID 544] [MainThread] [dramatiq.ForkProcess(0)] [INFO] Fork process 'dramatiq.middleware.prometheus:_run_exposition_server' is ready for action.
[2020-05-06 09:46:28,559] [PID 513] [MainThread] [dramatiq.WorkerProcess(3)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,569] [PID 512] [MainThread] [dramatiq.WorkerProcess(2)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,581] [PID 515] [MainThread] [dramatiq.WorkerProcess(5)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,596] [PID 514] [MainThread] [dramatiq.WorkerProcess(4)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,634] [PID 516] [MainThread] [dramatiq.WorkerProcess(6)] [INFO] Worker process is ready for action.
[2020-05-06 09:46:28,634] [PID 517] [MainThread] [dramatiq.WorkerProcess(7)] [INFO] Worker process is ready for action.
But when I import this function in an interpreter and use send
method on it...
from script_name import sq
sq.send(10)
...it waits for a few seconds and then raises a dramatiq.errors.ConnectionClosed
error:
dramatiq.errors.ConnectionClosed: AMQPConnectionError: (AMQPConnectorSocketConnectError: ConnectionRefusedError(10061, 'Unknown error'),)
It seems that this call is not able to send the message to dramatiq running inside WSL.
Note: I haven't installed RabbitMQ, but I assumed it's not required if I'm going to use Redis.