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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With