Uploaded image for project: 'Motor'
  1. Motor
  2. MOTOR-633

Collection.watch does not work with a session

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.3.1
    • Affects Version/s: 2.3
    • Component/s: None
    • None

      The following code crashes with

      AttributeError: 'AsyncIOMotorClientSession' object has no attribute '_txn_read_preference'
      

      changing `session=s` to `session=s.delegate` fixes the issue

      import asyncio
      import motor.motor_asyncio
      
      async def main():
      	client = motor.motor_asyncio.AsyncIOMotorClient()
      	async with await client.start_session() as s:
      		async with client.db.collection.watch(session=s) as change_stream:
      			async for change in change_stream:
      				print(change)
      
      asyncio.run(main())
      
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            arthur.darcet@gmail.com Arthur Darcet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: