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

TimeoutError changed in Python 3.8

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      ERROR: test_timeout_environment_variable (asyncio_tests.test_asyncio_tests.TestAsyncIOTests)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/home/travis/build/mongodb/motor/test/asyncio_tests/test_asyncio_tests.py", line 138, in test_timeout_environment_variable
          custom_timeout(self)
        File "/home/travis/build/mongodb/motor/test/asyncio_tests/__init__.py", line 214, in wrapped
          self.loop.run_until_complete(task)
        File "/opt/python/3.8.0/lib/python3.8/asyncio/base_events.py", line 608, in run_until_complete
          return future.result()
        File "/opt/python/3.8.0/lib/python3.8/asyncio/tasks.py", line 490, in wait_for
          raise exceptions.TimeoutError()
      asyncio.exceptions.TimeoutError
      

      Python 3.8 seems to have made a breaking change to the type of TimeoutError raised by asyncio. In 3.7 asyncio raises:

      >>> import concurrent.futures
      >>> help(concurrent.futures.TimeoutError)
      
      Help on class TimeoutError in module concurrent.futures._base:
      
      class TimeoutError(Error)
       |  The operation exceeded the given deadline.
       |
       |  Method resolution order:
       |      TimeoutError
       |      Error
       |      builtins.Exception
      ...
      

      In 3.8 asyncio raises:

      >>> import asyncio.exceptions
      >>> help(asyncio.exceptions.TimeoutError)
      
      Help on class TimeoutError in module asyncio.exceptions:
      
      class TimeoutError(builtins.Exception)
       |  The operation exceeded the given deadline.
       |
       |  Method resolution order:
       |      TimeoutError
       |      builtins.Exception
      ...
      

      Reported and fixed by https://github.com/mongodb/motor/pull/56.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: