回覆: Re: 回覆: Re: [Twisted-web] How to wait for a deferred object?

Suet Lung Cheung suetlung2003 at yahoo.com.hk
Sun Dec 4 23:52:27 MST 2005


Hi Paul,
     Thanks for your reply again. Your example works for me. I found the difference. I use a serviceCollection to include my service. Does it mean anything? my code is in this way...
 application = service.Application('chatroom')
 
 f = ChatService()
 serviceCollection = service.IServiceCollection(application)
 internet.TCPServer (1234, ChatFactoryFromService(f)).setServiceParent(serviceCollection)
 
and I have implemented stopService() in ChatService. Is it different if I use serviceCollection? Thanks again.
 
 Snow Dragon
 
Jean-Paul Calderone <exarkun at divmod.com> »¡¡G On Mon, 5 Dec 2005 11:52:11 +0800 (CST), Suet Lung Cheung  wrote:
>Hi Paul,
> 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.
>
> Snow Dragon
>

exarkun at boson:~$ cat > stop-service.py
from twisted.application import service
application = service.Application("stop-service demo")

class Demo(service.Service):
  def stopService(self):
    print "Stopping!"
Demo().setServiceParent(application)
exarkun at boson:~$ twistd -noy stop-service.py 
2005/12/05 00:23 EST [-] Log opened.
2005/12/05 00:23 EST [-] twistd SVN-Trunk (/usr/bin/python 2.4.2) starting up
2005/12/05 00:23 EST [-] reactor class: twisted.internet.selectreactor.SelectReactor
2005/12/05 00:23 EST [-] Loading stop-service.py...
2005/12/05 00:23 EST [-] Loaded.
2005/12/05 00:23 EST [-] Received SIGINT, shutting down.
2005/12/05 00:23 EST [-] Stopping!       < - - - - - - - - - stopService
2005/12/05 00:23 EST [-] Main loop terminated.
2005/12/05 00:23 EST [-] Server Shut Down.
exarkun at boson:~$ 

Jean-Paul

_______________________________________________
Twisted-web mailing list
Twisted-web at twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web



_______________________________________
 ë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/20051205/ab94eaec/attachment.htm


More information about the Twisted-web mailing list