[Twisted-web] How to do create a very simple tac file ?

Ivan bdfy at mail.ru
Thu Jul 14 11:35:00 EDT 2011

Thank you for example. I write a simple plugin for template:

from twisted.application import service, internet
from twisted.internet import utils, reactor
from twisted.python import log
from twisted.python import usage

class Options(usage.Options):

class TestService(service.Service):
    name = 'TestService'

    def __init__(self, reactor):
        self.reactor = reactor

    def startService(self):

    def Test(self):
        utils.getProcessOutputAndValue('/usr/bin/sleep', args = ['1000'])

def makeService(options):
    s = TestService(reactor)
    return s

It's work (twistd -n test ) , but kill pid ( without kill -9 ) don't work. I see a message "Main loop terminated" and script continue running. Why ?

14 июля 2011, 17:30 от Duncan McGreggor <duncan.mcgreggor at gmail.com>:

On Thu, Jul 14, 2011 at 7:05 AM, Thorne, Stephen <
stephen at thorne.id.au> wrote:
> On Thu, Jul 14, 2011 at 13:50, Ivan <
bdfy at mail.ru> wrote:
>> I have a very simple example:
>> from twisted.internet import protocol, utils, reactor
>> def start():
>>     utils.getProcessOutputAndValue('sleep',['1000'])
>> reactor.callWhenRunning(start)
>> reactor.run()
> I put together an example of how to create a 'complete' example
> application using twisted plugins (which are also run with 'twistd'
> but allow things like command line arguments) a few weeks ago.
> repo is here: 
> It shows how to do things in 'Service.startService', this approach
> would map to using a .tac file as well, with some munging.
> Stephen.

I gotta second this. This is the best example of Twisted plugins I've
seen yet. I know I'll regret saying this, but it's foolproof.


Twisted-web mailing list

Twisted-web at twistedmatrix.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20110714/9aed165f/attachment.htm 

More information about the Twisted-web mailing list