On Jun 20, 2011, at 7:39 AM, Phil Mayers wrote:
On 20/06/11 11:29, Orestis Markou wrote:
By "server" I mean my application's API, by "client" I mean someone else that will go and attach callbacks to deferreds I will return. I guess the question is, what is the best way to guard my application against callbacks that are doing a lot of work. But probably I'm confused by conflating the neglecting read() loop with starving the reactor.
It might be there's no way to do guarantee something like that, so it might be just that everyone should be careful about this.
I don't think you can stop callers of a function doing silly things with the return value.
+1. The best way to deal with this is to make your APIs nice and simple, and their implementation straightforward. If you try to do weird tricks to make callbacks on your Deferreds cooperative, then you might break an otherwise reasonable strategy on the part of the client code to be well-behaved on their part.
For the code that is itself trying to be well-behaved, there are things like twisted.internet.task.cooperate.