tornado.testing AsyncTestCase.wait() (v2.2)

85 views
Skip to first unread message

bergundy

unread,
Feb 8, 2012, 2:30:11 PM2/8/12
to Tornado Web Server
Consider the following test code:
----
from tornado.testing import AsyncTestCase
import time

class TestWait(AsyncTestCase):
def test_1(self):
self.io_loop.add_timeout(time.time() + 1, self.stop)
self.wait(timeout = 2)
self.io_loop.add_timeout(time.time() + 2, self.stop)
self.wait(timeout = 5)
----

When calling wait() the second time, the first timeout is still set in
the ioloop which causes the test to fail with the following traceback:

-----
Traceback (most recent call last):
File "/home/bergundy/test_wait.py", line 9, in test_1
self.wait(timeout = 5)
File "/netapp/dist/centos_5/i686/lib/python2.7/site-packages/tornado/
testing.py", line 169, in timeout_func
timeout)
AssertionError: Async operation timed out after 2 seconds
-----

Is this intended behavior? Am I doing something wrong?

Ben Darnell

unread,
Feb 9, 2012, 12:30:45 AM2/9/12
to python-...@googlegroups.com
This is a bug. The timeout feature was designed to catch runaway
tests that would otherwise run forever, so the timeout for any one
call to wait() was expected to be longer than the entire running time
of its test case. AsyncTestCase.wait should save the timeout handle
it creates and cancel it before returning.

-Ben

Roey Berman

unread,
Feb 13, 2012, 8:53:02 AM2/13/12
to python-...@googlegroups.com
I created a pull request for this issue: https://github.com/facebook/tornado/pull/460
Reply all
Reply to author
Forward
0 new messages