Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-4843

Async test suite should use a single event loop

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      After PYTHON-4725, an AsyncMongoClient can only be used on a single event loop because the SDAM and other various background tasks are bound to the loop used to open the client.

      For this reason, the async test suite should use a single event loop for all tests:
      https://pytest-asyncio.readthedocs.io/en/latest/how-to-guides/run_package_tests_in_same_loop.html

      import pytest
      pytestmark = pytest.mark.asyncio(loop_scope="package")
      

      Any tests for using multiple/different loops (eg PYTHON-4724) should be handwritten.

            Assignee:
            noah.stapp@mongodb.com Noah Stapp
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: