Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-17 Thread Mark Visser
Matt Perry wrote: > would swallow any exceptions thrown by deferred1 and continue on to > create deferred2. If you did: > > d.addCallback(foo) > d.addCallback(bar) > d.addCallback(baz) > > then an exception in "foo" would break the whole callback chain. You can also use addBoth(), which adds a ca

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-17 Thread Matt Perry
That way works, but the original problem was that a failure in one of them was stopping the whole callback chain. Missing from my example (but present in a past example) was a try/except around the yield keyword. So: ... try: yield deferred1 except: pass ... try: yield deferred2 except:

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-17 Thread Amaury Forgeot d'Arc
Hello, 2009/9/17 Matt Perry : > Make sure you're using the @inlineCallbacks decorator and the yield > statement referenced previously.  Without those you're just adding several > callbacks to the same Deferred; with them, the function will wait until the > Deferred fires before continuing. > > def

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-16 Thread Pet
On Thu, Sep 17, 2009 at 4:35 AM, Matt Perry wrote: > Make sure you're using the @inlineCallbacks decorator and the yield > statement referenced previously.  Without those you're just adding several > callbacks to the same Deferred; with them, the function will wait until the > Deferred fires befor

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-16 Thread Matt Perry
Make sure you're using the @inlineCallbacks decorator and the yield statement referenced previously. Without those you're just adding several callbacks to the same Deferred; with them, the function will wait until the Deferred fires before continuing. def logRequest(self, *arg, **kw): obj = co

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-16 Thread Pet
On Tue, Sep 15, 2009 at 6:21 PM, Pet wrote: > On Tue, Sep 15, 2009 at 5:19 PM, Mark Visser wrote: >> exar...@twistedmatrix.com wrote: >>> On 10:37 am, petshm...@googlemail.com wrote: I'd like to run several queries in background, some of them may fail. >>> >>> If you have a functio

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-15 Thread Pet
On Tue, Sep 15, 2009 at 5:19 PM, Mark Visser wrote: > exar...@twistedmatrix.com wrote: >> On 10:37 am, petshm...@googlemail.com wrote: >>> >>> I'd like to run several queries in background, some of them may fail. >>> >> >> If you have a function along the lines of this one: >> >>     def someInter

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-15 Thread Mark Visser
exar...@twistedmatrix.com wrote: > On 10:37 am, petshm...@googlemail.com wrote: >> >> I'd like to run several queries in background, some of them may fail. >> > > If you have a function along the lines of this one: > > def someInteractions(db): > interactions = [ > db.r

Re: [Twisted-Python] run queries in deffered, but not in transaction

2009-09-15 Thread exarkun
On 10:37 am, petshm...@googlemail.com wrote: >Hi, > >I'd like to run several queries in background, some of them may fail. >Currently, I do runInteraction for each query. Is there a way to run >them all in one deferred, so that if one of them fails, other are not >aborted? If you have a function a