DEV Community

Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on • Edited on

4 3

TIL: Tornado | Fix "tornado.util.TimeoutError: Operation timed out after 5 seconds"

Story

Whenever I debug my test for tornado code in the end I get this error

...
> raise TimeoutError('Operation timed out after %s seconds' % timeout)
E tornado.util.TimeoutError: Operation timed out after 5 seconds

.venv/lib/python3.7/site-packages/tornado/ioloop.py:575: TimeoutError
Enter fullscreen mode Exit fullscreen mode

Question

How to fix tornado.util.TimeoutError: Operation timed out after 5 seconds on tornado test debug?

Answer

This is due ASYNC_TEST_TIMEOUT environment variable
From docs

In the event of a timeout, an exception will be thrown. The default timeout is 5 seconds; it may be overridden with a timeout keyword argument or globally with the ASYNC_TEST_TIMEOUT environment variable.

And could be fixed by setting this variable to a bigger value in seconds

$ # running tests with ASYNC_TEST_TIMEOUT set to 10 minutes
$ ASYNC_TEST_TIMEOUT=600 python -m unittest
Enter fullscreen mode Exit fullscreen mode

or if you are using pytest with pytest-tornado plugin by passing --async-test-timeout argument to pytest command

$ pytest --async-test-timeout=600
Enter fullscreen mode Exit fullscreen mode

Links

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more