Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I detect long blocking functions in Tornado application

I have a Tornado application and sometimes somebody adds a code that blocks for an inappropriate time.

How do I detect such functions, maybe even log which handler/coroutine method blocks for a time longer than, say, 50ms?

I'm looking at _make_coroutine_wrapper() in tornado.gen, and don't see a way to cut in, except for modifying the source - which is ok for a one-time debugging, but is there a better way?

like image 787
Victor Sergienko Avatar asked Oct 29 '14 18:10

Victor Sergienko


1 Answers

You can use the IOLoop.set_blocking_log_threshold method. set_blocking_log_threshold(0.050) will print a stack trace any time the IOLoop is blocked for longer than 50ms.

like image 143
Ben Darnell Avatar answered Oct 06 '22 02:10

Ben Darnell