<div id="RTEContent">Hi Paul,<br> Thanks for your help. However it seems doesn't work. When I press Ctrl-C, it even doesn't call the stopService() function. I print a "Hello World" inside the function but it doesn't say hello to the world. And I've tried returning a Deferred from this function. However it quit before the callback is called. Can u give advice on this? Do u know where can I find some example about this? Thanks a lot.<br> <br> Snow Dragon<br><br><b><i>Jean-Paul Calderone <exarkun@divmod.com></i></b> 弧<blockquote class="replbq" style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"> On Fri, 2 Dec 2005 12:54:48 +0800 (CST), Suet Lung Cheung <suetlung2003 @yahoo.com.hk=""> wrote:<br>> Hi everyone,<br>><br>> 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<br><br>Services receive shutdown notification via their stopService() method. The method is called all the way down the service hierarchy when a twistd process is preparing to terminate. If a stopService() method returns a Deferred, the Deferred will be allowed to fire before shutdown completes. So you probably want a custom Service implementation which knows about the Deferreds from your connectionLost() and can return them from stopService() if
necessary.<br><br>Jean-Paul<br><br>_______________________________________________<br>Twisted-web mailing list<br>Twisted-web@twistedmatrix.com<br>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web<br></suetlung2003></blockquote><br></div><p>_______________________________________<br> 離線訊息 - Yahoo! Messenger<br> 就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。<br> http://messenger.yahoo.com.hk