[Twisted-Python] How to detect when there is nothing waiting in the event queue

Mark Visser markv at lumierevfx.com
Mon Sep 14 12:11:46 EDT 2009


Hi, we've been using Twisted in an internal project for the past 4 
months. It's a system that polls for events from a web source (looping 
call) and also accepts connections via perspective broker. Each of these 
events is turned into a series of Deferreds that run various tasks. Some 
of these tasks are long-running and can take several hours to complete.

Because of this, it's very difficult to restart the server when we roll 
out a new release.

I've added a signal handler to catch SIGHUP and call stop() on the 
looping call and stopListening() on the perspective broker Root. How can 
I detect when all remaining Deferreds have fired so I can stop the 
reactor safely, without stranding any running processes?

thanks

-- 
Mark Visser, Software Director
Lumière VFX
Email: markv at lumierevfx.com
Phone: +1-514-316-1080 x3030




More information about the Twisted-Python mailing list