Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Glyph Lefkowitz
Chris, My original reply jumped into the middle of the thread and I didn't completely understand what you were asking. Let's get back to your original message: On Sep 28, 2010, at 9:48 AM, Chris Withers wrote: > The loop() function is supposed to be a "catch all and report" error handler. > H

Re: [Twisted-Python] Small practice application

2010-09-30 Thread Glyph Lefkowitz
On Sep 30, 2010, at 1:51 AM, Zubin Mithra wrote: > However, I am confused on how to write data over to a particular player(0 or > 1). Is there any way I could choose to write to a particular object? > Sure, make self.factory.connections into a dictionary which maps player names to connection

Re: [Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]

2010-09-30 Thread Phil Mayers
On 30/09/10 16:10, Chris Withers wrote: > On 30/09/2010 15:53, Phil Mayers wrote: >>> So, I appear to be back to the case where I can either gracefully handle >>> the exception *or* gracefully handle the errback, but not both? >> >> It should be possible if using Twisted APIs correctly to reliably

Re: [Twisted-Python] Unable to start twistd service on Ubuntu 10.04 when using pseudo terminal

2010-09-30 Thread Žiga Seilnacht
Hello, Garret Heaton wrote: > I've simplified this issue down and am able to reproduce it without > Twisted: http://gist.github.com/603154 > > Still not sure what the cause is, so if anyone has any ideas I'd love to > hear them. Thanks! > The behavior that you are seeing seems to be related to

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Chris Withers
On 30/09/2010 15:33, exar...@twistedmatrix.com wrote: >> 2010-09-30 15:07:03,161 ERROR : log (22194|7f41910b26e0): >> Unhandled Error >> Traceback (most recent call last): >>File "test_looping.py", line 47, in >> reactor.run() >>File "/twisted/internet/base.py", line 1166, in

Re: [Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]

2010-09-30 Thread Chris Withers
On 30/09/2010 15:53, Phil Mayers wrote: >> So, I appear to be back to the case where I can either gracefully handle >> the exception *or* gracefully handle the errback, but not both? > > It should be possible if using Twisted APIs correctly to reliably > capture errors. > > If it is not, that is a

Re: [Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]

2010-09-30 Thread Phil Mayers
On 30/09/10 15:35, Chris Withers wrote: > On 30/09/2010 15:23, Phil Mayers wrote: >>> def loop(): >>> d = maybeDeferred(doStuff) >>> d.addErrback(partial(log.err,_why='Unhandled scheduled exception')) >> >>> So, how come my log.err doesn't get used for the AttributeError on >>> connector? >> >> If

Re: [Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]

2010-09-30 Thread exarkun
On 02:35 pm, ch...@simplistix.co.uk wrote: >On 30/09/2010 15:23, Phil Mayers wrote: >>>def loop(): >>>d = maybeDeferred(doStuff) >>>d.addErrback(partial(log.err,_why='Unhandled scheduled exception')) >> >>>So, how come my log.err doesn't get used for the AttributeError on >>>connector? >> >>If you

[Twisted-Python] The Real Error (tm) [was Re: how to write a safe catch-all]

2010-09-30 Thread Chris Withers
On 30/09/2010 15:23, Phil Mayers wrote: >> def loop(): >> d = maybeDeferred(doStuff) >> d.addErrback(partial(log.err,_why='Unhandled scheduled exception')) > >> So, how come my log.err doesn't get used for the AttributeError on >> connector? > > If you mean in your most recent "test_looping.py" exa

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread exarkun
On 02:13 pm, ch...@simplistix.co.uk wrote: >On 30/09/2010 14:39, Jonathan Lange wrote: >>On Thu, Sep 30, 2010 at 2:36 PM, Chris Withers >>wrote: >>... >>> >>>Is there any way I can get both errbacks *and* exceptions handled >>>nicely in >>>my `loop` call? >> >>You know about defer.maybeDeferred,

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Phil Mayers
On 30/09/10 15:13, Chris Withers wrote: > On 30/09/2010 14:39, Jonathan Lange wrote: >> On Thu, Sep 30, 2010 at 2:36 PM, Chris Withers >> wrote: >> ... >>> >>> Is there any way I can get both errbacks *and* exceptions handled nicely in >>> my `loop` call? >> >> You know about defer.maybeDeferred

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Chris Withers
On 30/09/2010 14:39, Jonathan Lange wrote: > On Thu, Sep 30, 2010 at 2:36 PM, Chris Withers wrote: > ... >> >> Is there any way I can get both errbacks *and* exceptions handled nicely in >> my `loop` call? > > You know about defer.maybeDeferred, right? Yep, the problem is with `loop` implemented

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Chris Withers
On 30/09/2010 14:46, Phil Mayers wrote: > On 30/09/10 14:36, Chris Withers wrote: >> >> Indeed, but, as I keep saying, I need to build a scheduler that's >> resilient to errors in the tasks its running ;-) > > Sure. > >> Most prominent is reactor.callLater. >> >> ...which I'm not actually us

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Phil Mayers
On 30/09/10 14:36, Chris Withers wrote: > > Indeed, but, as I keep saying, I need to build a scheduler that's > resilient to errors in the tasks its running ;-) Sure. > >>> Most prominent is reactor.callLater. > > ...which I'm not actually using, it was just a small-as-possible way I > could simu

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Jonathan Lange
On Thu, Sep 30, 2010 at 2:36 PM, Chris Withers wrote: ... > > Is there any way I can get both errbacks *and* exceptions handled nicely in > my `loop` call? You know about defer.maybeDeferred, right? jml ___ Twisted-Python mailing list Twisted-Python@t

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Chris Withers
On 30/09/2010 14:03, Phil Mayers wrote: On 30/09/10 13:44, Phil Mayers wrote: This is because (as you've discovered) there are circumstances when a function is called in Twisted where the exception can't propagate "up" to the caller, because the caller is no longer higher in the call stack. I

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Phil Mayers
On 30/09/10 13:44, Phil Mayers wrote: > This is because (as you've discovered) there are circumstances when a > function is called in Twisted where the exception can't propagate "up" > to the caller, because the caller is no longer higher in the call stack. > Most prominent is reactor.callLater.

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Phil Mayers
On 30/09/10 11:48, Chris Withers wrote: > On 30/09/2010 04:45, exar...@twistedmatrix.com wrote: >> On 12:52 am, ch...@simplistix.co.uk wrote: >>> >>> Because I haven't found any permutation that doesn't result in the >>> LoopingCall's calls to `loop` from stopping after the exception. >>> >>> I wou

Re: [Twisted-Python] how to write a safe catch-all

2010-09-30 Thread Chris Withers
On 30/09/2010 04:45, exar...@twistedmatrix.com wrote: > On 12:52 am, ch...@simplistix.co.uk wrote: >> >> Because I haven't found any permutation that doesn't result in the >> LoopingCall's calls to `loop` from stopping after the exception. >> >> I would be more than ecstatic to be proved wrong ;-)