Collection.watch does not work with a session

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Major - P3
    • 2.3.1
    • Affects Version/s: 2.3
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Arthur Darcet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: