[Twisted-Python] run queries in deffered, but not in transaction
petshmidt at googlemail.com
Tue Sep 15 12:21:05 EDT 2009
On Tue, Sep 15, 2009 at 5:19 PM, Mark Visser <markv at lumierevfx.com> wrote:
> exarkun at twistedmatrix.com wrote:
>> On 10:37 am, petshmidt at 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 = [
>> Then a failure in one shouldn't affect two or three; likewise for any
>> other failure or combination of failures. They are naturally (ugh, not
>> a good word, but I can't think of a better one) independent. You have
>> to go out of your way to associate them somehow.
> I think he might mean he wants them to run sequentially, even if one fails.
> You can do that explicitly via @inlineCallbacks like this:
> def someInteractions(db):
> yield db.runInteraction(one)
> yield db.runInteraction(two)
> yield db.runInteraction(three)
> Or with callback/errbacks, like this:
> def someInteractions(db)
> d = db.runInteraction(one).addBoth(db.runInteraction,
> two).addBoth(db.runInteraction, three)
Yes, I'd like run them sequentially, it was not clear for me, how to
do it in one deferred.
I will try your suggestions out.
Thanks for help!
> addBoth is a convenience method that adds the same function as a
> callback and an errback:
> Mark Visser, Software Director
> Lumière VFX
> Email: markv at lumierevfx.com
> Phone: +1-514-316-1080 x3030
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python