[Twisted-web] How to wait for a deferred object?

Suet Lung Cheung suetlung2003 at yahoo.com.hk
Thu Dec 1 21:54:48 MST 2005


  Hi everyone,
  
 I am writing a TCP server program using twisted. I cannot use pb since the client side is not in python. I decided to use twisted.application and run it as internet.TCPServer(...). My problem is that I want to make it save something to a database whenever a connection closed. I do this in returning a deferred under Protocol.connectionLost(). I would like to make this work when the server is shut down. However when the server is down, it doesn't wait for the deferred to finish the callback and quit. I would like to make it save to db as normal but the server will wait for all deferred has called back.  Is there anyway I can do this? Any suggestions? Thanks a lot
  
  Snow Dragon

_______________________________________
 ëx¾€ÓÏ¢ - Yahoo! Messenger
 ¾ÍËãÄã›]ÓÐÉϾW£¬ÄãµÄÅóÓÑÈÔ¿ÉÒÔÁôÏÂӍϢ½oÄ㣬®”ÄãÉϾW•r¾ÍÄÜÁ¢¼´¿´µ½£¬ÈκÎÕfÔ’¶¼ƒÓ×ßʧ¡£
  http://messenger.yahoo.com.hk 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20051202/66bdea1a/attachment.htm


More information about the Twisted-web mailing list