[Twisted-Python] Re: reactor.stop stops entire twistd
Anthony Tarlano
tarlano at docomolab-euro.com
Wed Jul 28 04:11:52 MDT 2004
Liming,
You may want to read the fine documentation howto sections...
http://www.twistedmatrix.com/documents/current/howto/
I think if you put a little time into reading, all your questions will
be answered.
Anthony
Tsai Li Ming wrote:
> Christopher,
>
> We have the following class that is instantiated within the sever code
> that is using twistd to issue system calls.
>
> class System:
> result = None
> status = None
> cmd = ''
>
>
> def __init__(self, cmd, args=[]):
> self.cmd = cmd
> self.args = args
>
>
> def ok(self, result):
> self.result = result
> self.status = 0
> reactor.stop()
>
>
> def err(self, err):
> self.result = err.getErrorMessage()
> self.status = 1
> reactor.stop()
>
>
> def run(self):
> d = utils.getProcessOutput(self.cmd, self.args, os.environ)
> d.addCallback(self.ok)
> d.addErrback(self.err)
> reactor.run()
>
>
> def getResult(self):
> if self.status == None: self.status = 0
> if self.result[-1:] == '\n': self.result = self.result[:-1]
>
>
> return self.status, self.result
>
>
> Since the reactor is already running, how do I actually use Deferred?
>
> Many thanks,
> Liming
>
>
> Christopher Armstrong wrote:
>
>> On Wed, 28 Jul 2004 17:07:36 +0800, Tsai Li Ming
>> <mailinglist at ltsai.com> wrote:
>>
>>> Ok. then how do I aviod using reactor.start() and reactor.stop() for
>>> getProcessOutut?
>>
>>
>>
>> Well, since you're using twistd, the reactor is already running, so
>> you don't need to call reactor.run(). And you shouldn't be calling
>> reactor.stop(), because you said you didn't want to stop the reactor.
>>
>> So, just don't call them. But the fact that I need to say something so
>> obvious makes me think I'm not grasping the whole picture. If my
>> explanation so far is insufficient, can you show more code?
>>
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
--
____________________________________________________________
*Anthony Tarlano
Researcher - Future Networking Laboratory*
*DoCoMo Communications Laboratories Europe GmbH** *
*Landsberger Strasse 308-312 *
*80687 Munich Germany*
*Tel:** +**49 89 56 824 212*
*Cell: ** +**49 177 341 3758*
*Fax:** ** ** ** **+**49 89 56 824 300*
mailto:tarlano at docomolab-euro.com
http://www.docomolab-euro.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20040728/9a183fbb/attachment.html>
More information about the Twisted-Python
mailing list