0

I have a problem with one my async tests: tornado seems not to be up and running (I get 599s), even though it is started as a fixture. I would like to verify that it is indeed running, by doing the following:

  1. Start the test
  2. Before the requests are actually sent to tornado, I would like my code to "sleep" for a long time so that I can manually check with the browser that tornado is indeed running.

How can I tell python to sleep without blocking the async loop? If I do time.sleep, the whole process (and thus the loop) is not responsive for the duration of the sleep.

blueFast
  • 41,341
  • 63
  • 198
  • 344
  • `time.sleep()` is [supposed to suspend only the current thread](http://stackoverflow.com/questions/92928/time-sleep-sleeps-thread-or-process). Can you provide some code, so that we better understand the context? – Leon Feb 08 '17 at 10:49

2 Answers2

1

Both of your questions are answered in Tornado's FAQ:

http://www.tornadoweb.org/en/latest/faq.html

Use yield gen.sleep(1) to wait 1 second while letting other tasks run on the event loop, or use IOLoop.current().add_timeout(1, callback) to run a callback one second later.

Don't use your browser to verify that your application handles multiple requests concurrently: the browser itself may not allow concurrent requests. Use curl instead.

A. Jesse Jiryu Davis
  • 23,641
  • 4
  • 57
  • 70
  • Thanks. The browser was not supposed to be used as multiple requests tester, just as a manual check on whether the server was really started or not. It turned out to be a problem with several ioloops being implicitly defined, while only one was being started by the test framework (py.test). So, it really was a problem with the server not being up and running. – blueFast Feb 09 '17 at 08:59
0

You may check your code whether your request method is POST or PUT, I get the 599 Response Code when I use method POST and didn't post a data, and it gones when I added data.

error: res = self.fetch('/', method='POST')

fixed: res = self.fetch('/', method='POST', data={})

Shin
  • 81
  • 1
  • 4