Search code examples
pythonmultithreadingtwistedreactorresource-leak

Does each reactor run in it's own thread?


Profiling my twisted app I am seeing that twisted/application/app.py:startReactor was called 496 times. Apart of this, I am seeing thread leaking: ~500 threads were created by the app, most of them are idle in FUTEX_WAIT_PRIVATE. During this profiling simple load test were run: ~1rps.

Does it mean that somewhere in the code reactor.run() is leaking? Where should I start digging?


Solution

  • In general, no. reactor.run does not start a thread. However, if you have an application that starts 496 reactors then maybe it starts threads in which to run each of them.