<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Liming,<br>
<br>
You may want to read the fine documentation howto sections...
<a class="moz-txt-link-freetext" href="http://www.twistedmatrix.com/documents/current/howto/">http://www.twistedmatrix.com/documents/current/howto/</a><br>
<br>
<br>
I think if you put a little time into reading, all your questions will
be answered.<br>
<br>
Anthony<br>
<br>
<br>
Tsai Li Ming wrote:
<blockquote cite="midce7rlm$1p5$1@sea.gmane.org" type="cite">Christopher,
  <br>
  <br>
We have the following class that is instantiated within the sever code
that is using twistd to issue system calls.
  <br>
  <br>
class System:
  <br>
&nbsp;&nbsp;&nbsp; result = None
  <br>
&nbsp;&nbsp;&nbsp; status = None
  <br>
&nbsp;&nbsp;&nbsp; cmd = ''
  <br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp; def __init__(self, cmd, args=[]):
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.cmd = cmd
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.args = args
  <br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp; def ok(self, result):
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.result = result
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.status = 0
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.stop()
  <br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp; def err(self, err):
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.result = err.getErrorMessage()
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.status = 1
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.stop()
  <br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp; def run(self):
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d = utils.getProcessOutput(self.cmd, self.args, os.environ)
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.addCallback(self.ok)
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d.addErrback(self.err)
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reactor.run()
  <br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp; def getResult(self):
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.status == None: self.status = 0
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if self.result[-1:] == '\n': self.result = self.result[:-1]
  <br>
  <br>
  <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return self.status, self.result
  <br>
  <br>
  <br>
Since the reactor is already running, how do I actually use Deferred?
  <br>
  <br>
Many thanks,
  <br>
Liming
  <br>
  <br>
  <br>
Christopher Armstrong wrote:
  <br>
  <blockquote type="cite">On Wed, 28 Jul 2004 17:07:36 +0800, Tsai Li
Ming <a class="moz-txt-link-rfc2396E" href="mailto:mailinglist@ltsai.com">&lt;mailinglist@ltsai.com&gt;</a> wrote:
    <br>
    <br>
    <blockquote type="cite">Ok. then how do I aviod using
reactor.start() and reactor.stop() for
      <br>
getProcessOutut?
      <br>
    </blockquote>
    <br>
    <br>
Well, since you're using twistd, the reactor is already running, so
    <br>
you don't need to call reactor.run(). And you shouldn't be calling
    <br>
reactor.stop(), because you said you didn't want to stop the reactor.
    <br>
    <br>
So, just don't call them. But the fact that I need to say something so
    <br>
obvious makes me think I'm not grasping the whole picture. If my
    <br>
explanation so far is insufficient, can you show more code?
    <br>
    <br>
  </blockquote>
  <br>
  <br>
_______________________________________________
  <br>
Twisted-Python mailing list
  <br>
<a class="moz-txt-link-abbreviated" href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a>
  <br>
<a class="moz-txt-link-freetext" href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a>
  <br>
  <br>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<meta http-equiv="Content-Type" content="text/html; ">
<meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 9">
<meta name="Originator" content="Microsoft Word 9">
<link rel="File-List" href="./sign_files/filelist.xml">
<title>____________________________________________________________</title>
<!--[if gte mso 9]><xml>
 <o:DocumentProperties>
  <o:Author>tarlano</o:Author>
  <o:Template>Normal</o:Template>
  <o:LastAuthor>tarlano</o:LastAuthor>
  <o:Revision>3</o:Revision>
  <o:TotalTime>3</o:TotalTime>
  <o:Created>2002-07-04T07:46:00Z</o:Created>
  <o:LastSaved>2003-04-08T09:59:00Z</o:LastSaved>
  <o:Pages>1</o:Pages>
  <o:Words>68</o:Words>
  <o:Characters>389</o:Characters>
  <o:Lines>3</o:Lines>
  <o:Paragraphs>1</o:Paragraphs>
  <o:CharactersWithSpaces>477</o:CharactersWithSpaces>
  <o:Version>9.3821</o:Version>
 </o:DocumentProperties>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:Compatibility>
   <w:UseFELayout/>
   <w:ApplyBreakingRules/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:536871559 0 0 0 415 0;}
@font-face
        {font-family:"MS P????";
        panose-1:0 0 0 0 0 0 0 0 0 0;
        mso-font-alt:"Times New Roman";
        mso-font-charset:0;
        mso-generic-font-family:roman;
        mso-font-format:other;
        mso-font-pitch:auto;
        mso-font-signature:1 134676480 16 0 131072 0;}
 /* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-parent:"";
        margin:0cm;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:12.0pt;
        font-family:"Times New Roman";
        mso-fareast-font-family:"Times New Roman";}
h1
        {mso-style-next:Normal;
        margin:0cm;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        mso-outline-level:1;
        mso-layout-grid-align:none;
        text-autospace:none;
        font-size:10.0pt;
        mso-bidi-font-size:12.0pt;
        font-family:Verdana;
        mso-font-kerning:0pt;
        font-weight:normal;}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;
        text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;
        text-underline:single;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 90.0pt 72.0pt 90.0pt;
        mso-header-margin:36.0pt;
        mso-footer-margin:36.0pt;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->
</style><!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1027"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1"/>
 </o:shapelayout></xml><![endif]-->
<o:smarttagtype
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="place"
 _x002f=""></o:smarttagtype>
<div class="Section1">
<p class="MsoNormal"><span style="" lang="EN-US">____________________________________________________________
<br>
<b><span style="color: navy;">Anthony Tarlano <br>
Researcher - Future Networking Laboratory</span></b><br>
</span><b><span style="font-size: 8pt;" lang="EN-US">DoCoMo
Communications Laboratories <st1:place>Europe</st1:place> GmbH</span></b><b><span
 style="font-size: 8pt;" lang="EN-US"> </span></b><span style=""
 lang="EN-US"><br>
</span><b><span style="font-size: 8pt;" lang="DE">Landsberger
Strasse 308-312<span style="">&nbsp;&nbsp;&nbsp; </span></span></b><span style=""
 lang="EN-US"><br>
</span><b><span style="font-size: 8pt;" lang="DE">80687
Munich Germany</span></b><span style="" lang="EN-US"> <br>
</span><b><span style="font-size: 8pt;" lang="DE">Tel:</span></b><b><span
 style="font-size: 8pt; font-family: &quot;MS P????&quot;;" lang="DE"><span
 style="">&nbsp;&nbsp;&nbsp; </span>+</span></b><b><span style="font-size: 8pt;"
 lang="DE">49 89 56 824 212</span></b><span style="" lang="EN-US"> <br>
</span><b><span style="font-size: 8pt;" lang="EN-US">Cell:<span style="">&nbsp;
</span></span></b><b><span
 style="font-size: 8pt; font-family: &quot;MS P????&quot;;" lang="EN-US"><span
 style="">&nbsp;</span>+</span></b><b><span style="font-size: 8pt;"
 lang="EN-US">49 177 341 3758</span></b><span style="" lang="EN-US"> <br>
</span><b><span style="font-size: 8pt;" lang="EN-US">Fax:</span></b><b><span
 style="font-size: 8pt; font-family: &quot;MS P????&quot;;" lang="EN-US"> </span></b><b><span
 style="font-size: 8pt;" lang="EN-US">&nbsp;</span></b><b><span
 style="font-size: 8pt; font-family: &quot;MS P????&quot;;" lang="EN-US"> </span></b><b><span
 style="font-size: 8pt;" lang="EN-US">&nbsp;</span></b><b><span
 style="font-size: 8pt; font-family: &quot;MS P????&quot;;" lang="EN-US">+</span></b><b><span
 style="font-size: 8pt;" lang="EN-US">49 89 56 824 300</span></b><span
 style="" lang="EN-US"> </span><span style="font-size: 8pt;"
 lang="EN-US"><o:p></o:p></span></p>
<address><span style="font-size: 8pt; font-family: &quot;MS P????&quot;;"
 lang="EN-US"><a href="mailto:tarlano@docomolab-euro.com"><span
 style="font-size: 12pt; font-family: &quot;Times New Roman&quot;;">mailto:tarlano@docomolab-euro.com</span></a>
<o:p></o:p></span></address>
<address><span style="font-family: Arial;" lang="EN-US"><a
 href="http://www.docomolab-euro.com/"><span
 style="font-family: &quot;Times New Roman&quot;;">http://www.docomolab-euro.com/</span></a>
<o:p></o:p></span></address>
<p class="MsoNormal"><span style="font-family: Arial;" lang="EN-US">&nbsp;</span><span
 style="" lang="EN-US"> </span><span style="font-family: Arial;"
 lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="" lang="EN-US">&nbsp;<o:p></o:p></span></p>
</div>
</div>
</body>
</html>