aredis icon indicating copy to clipboard operation
aredis copied to clipboard

CancelledError exception is not propagated

Open sam-mosleh opened this issue 5 years ago • 0 comments

Checklist

  • Python version: 3.8.2
  • Using hiredis or just Python parser
  • Using uvloop or just asyncio event loop
  • Does issue exists against the master branch 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

sam-mosleh avatar Jan 03 '21 08:01 sam-mosleh