I’m running sanic with gunicorn, and nats.io
Sometime i got this error and how can i make it self-restart or making gunicorn auto restart the workers ?
Exception ignored in: <generator object Client.subscribe.<locals>.wait_for_msgs at 0x7fa6c47d3a50>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/nats/aio/client.py", line 721, in wait_for_msgs
File "/usr/local/lib/python3.7/asyncio/queues.py", line 161, in get
File "uvloop/loop.pyx", line 1250, in uvloop.loop.Loop.call_soon
File "uvloop/loop.pyx", line 603, in uvloop.loop.Loop._call_soon
File "uvloop/loop.pyx", line 607, in uvloop.loop.Loop._call_soon_handle
File "uvloop/loop.pyx", line 636, in uvloop.loop.Loop._check_closed
RuntimeError: Event loop is closed
Exception ignored in: <generator object Client.subscribe.<locals>.wait_for_msgs at 0x7fa6c47d3b50>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/nats/aio/client.py", line 721, in wait_for_msgs
File "/usr/local/lib/python3.7/asyncio/queues.py", line 161, in get
File "uvloop/loop.pyx", line 1250, in uvloop.loop.Loop.call_soon
File "uvloop/loop.pyx", line 603, in uvloop.loop.Loop._call_soon
File "uvloop/loop.pyx", line 607, in uvloop.loop.Loop._call_soon_handle
File "uvloop/loop.pyx", line 636, in uvloop.loop.Loop._check_closed
RuntimeError: Event loop is closed
btw, what is the correct way to keep my nats subscribers running on sanic, their example give not much
nc = NATS()
await nc.connect(servers=["nats://demo.nats.io:4222"])
future = asyncio.Future()
async def cb(msg):
nonlocal future
future.set_result(msg)
await nc.subscribe("updates", cb=cb)
await nc.publish("updates", b'All is Well')
await nc.flush()
# Wait for message to come in
msg = await asyncio.wait_for(future, 1)