Q: What is likely the reason that causes tornado ioloop to stall while stopping it? I have a tornado application that keep receiving and processing websocket messages from 10 websocket connections. The program will restart every 1 hour. I add a simple line: 
ioloop.call_later(3600, ioloop.stop)

to make the ioloop stop.
But what I found is that sometimes the program stalled for 4-5 minutes when it is supposed to call ioloop.stop and exit.
I'm aware that the open websocket is not cleaned up properly when ioloop is stopped. Actually, when the program stalled, using netstat I can see that the websocket connections are still open, and recv-Q is filled with messages.
So my question is what causes the program to stall and why? Thanks in advance.

A: Now I know the answer, because I used python ThreadPoolExecutor to run some blocking operations, and when ThreadPoolExecutor is shutting down, it wait until all futures are resolved.
