<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>Unhandled error in Deferred with twisted-8.2.0, but not with twisted-2.1.0</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Am currently trying to upgrade to twisted-8.2.0.&nbsp; For some reason, twisted-8.2.0 thinks my deferred below was gc'd with an unhandled error, and tells me about it upon reactor exit.&nbsp; With python-2.4.2/twisted-2.1.0, no issues.&nbsp; With python-2.6.1/twisted-8.2.0, I see these issues.&nbsp; Any ideas why?&nbsp; Thanks.</FONT></P>

<P><FONT SIZE=2 FACE="Arial">$ cat ./deferred-errors.py</FONT>

<BR><FONT SIZE=2 FACE="Arial">#!/usr/bin/env python</FONT>

<BR><FONT SIZE=2 FACE="Arial">import datetime, logging, os, random, re, shutil, socket</FONT>

<BR><FONT SIZE=2 FACE="Arial">import subprocess, sys, tempfile, threading, time, traceback</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">from twisted.internet&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import reactor</FONT>

<BR><FONT SIZE=2 FACE="Arial">from twisted.internet&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import defer</FONT>

<BR><FONT SIZE=2 FACE="Arial">from twisted.internet.utils import getProcessOutput</FONT>

<BR><FONT SIZE=2 FACE="Arial">from twisted.python&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import log</FONT>

<BR><FONT SIZE=2 FACE="Arial">import twisted</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">print 'twisted version is', twisted.__version__</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">def foo():</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; d = getProcessOutput('/bin/hostnameX')</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; def cb(result):</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'cb: %s' % (result)</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; def eb(failure):</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'eb caught the failure!'</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; d.addCallback(cb)</FONT>

<BR><FONT SIZE=2 FACE="Arial">&nbsp;&nbsp;&nbsp; d.addErrback(eb)</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">reactor.callWhenRunning(foo)</FONT>

<BR><FONT SIZE=2 FACE="Arial">reactor.callLater(3, reactor.stop)</FONT>

<BR><FONT SIZE=2 FACE="Arial">reactor.run()</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">$ /sw/external/python-2.4.2/bin/python ./deferred-errors.py </FONT>

<BR><FONT SIZE=2 FACE="Arial">twisted version is 2.1.0</FONT>

<BR><FONT SIZE=2 FACE="Arial">eb caught the failure!</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">$ /sw/external/python-2.6.1/bin/python ./deferred-errors.py </FONT>

<BR><FONT SIZE=2 FACE="Arial">twisted version is 8.2.0</FONT>

<BR><FONT SIZE=2 FACE="Arial">eb caught the failure!</FONT>

<BR><FONT SIZE=2 FACE="Arial">Unhandled error in Deferred:</FONT>

<BR><FONT SIZE=2 FACE="Arial">Traceback (most recent call last):</FONT>

<BR><FONT SIZE=2 FACE="Arial">Failure: twisted.internet.error.ProcessTerminated: A process has ended with a probable error condition: process ended with exit code 1.</FONT></P>

</BODY>
</HTML>