回覆： 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
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.
Jean-Paul Calderone <exarkun at divmod.com> »¡¡G On Mon, 5 Dec 2005 11:52:11 +0800 (CST), Suet Lung Cheung wrote:
> 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")
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:~$
Twisted-web mailing list
Twisted-web at twistedmatrix.com
ëx¾ÓÏ¢ - Yahoo! Messenger
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-web