How to identify long blocking functions in a Tornado application

I have a Tornado application, and sometimes someone adds code that blocks the wrong time.

How to detect such functions, maybe even write down which handler / coprocessor method is blocked for a longer time than, say, 50 ms?

I look at _make_coroutine_wrapper() in tornado.gen and see no way to cut, except changing the source - this is fine for one-time debugging, but is there a better way?

+5
source share
1 answer

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

+17
source

Source: https://habr.com/ru/post/1205802/


All Articles