Search code examples
tornado

How to profile tornado callbacks


Is there an easy way to profile and/or trace the order of callbacks being run in Tornado's IOLoop and the callback duration? I know about IOLoop.set_blocking_log_threshold() for seeing if something is blocked and taking a long time, but I am more interested in the work being done by the IOLoop and what tasks it is running.

I can use python's profiling libraries or run it in a debugger, but was just wondering if there was an easy switch to flip to dump that info to the logger or something.


Solution

  • There's nothing built-in to Tornado for this, but you can use general-purpose profiling tools. Stack-sampling profilers are well-suited for collecting profile data from running services including Tornado. I know that Plop works to profile Tornado applications and I think nylas-perftools does too.