aredis
aredis copied to clipboard
CancelledError exception is not propagated
Checklist
- Python version: 3.8.2
- Using hiredis or just Python parser
- Using uvloop or just asyncio event loop
- Does issue exists against the
masterbranch of aredis? Yes
Steps to reproduce
import asyncio
import aredis
async def read_loop():
redis = aredis.StrictRedis()
pubsub = redis.pubsub()
await pubsub.subscribe("sample")
print("listening started")
while True:
message = await pubsub.get_message()
print(message)
async def main():
task = asyncio.create_task(read_loop())
await asyncio.sleep(1)
task.cancel()
asyncio.run(main())
Expected behavior
The task should get canceled
Actual behavior
- asyncio.CancelledError is not propagated and the code above will run forever. It prints:
listening started
{'type': 'subscribe', 'pattern': None, 'channel': b'sample', 'data': 1}
None
None