On Thu, Mar 22, 2012 at 2:17 PM, Itamar Turner-Trauring
<ita...@itamarst.org> wrote:
> On 03/22/2012 08:05 AM, Uri Okrent wrote:
>> This implies that twisted can (and will) switch contexts from one
>> deferred to another even in the middle of execution of the first
>> deferred, correct?
>
> No. Deferreds are just slightly nicer callbacks. They have nothing to do
> with the event loop, or scheduling, or context switching.

Maybe I should clarify my question:

thing = 0
def a():
    thing += 1
    thing += 1
    thing += 1
    thing += 1
    thing += 1

def b():
    thing = 0

def show_thing():
    print thing

a.addCallback(show_thing)
b.addCallback(show_thing)

given the two deferreds 'a' and 'b', with 'a' being called first, it
is possible for twisted to jump to 'b' in the middle of 'a' correct?
I.e., when show_thing runs after 'b' is finished it will always print
0 because thing was set to 0 by 'b', but when show_thing runs as the
callback for 'a', it will print something between 0 and 5 and it is
non-deterministic, because 'b' may have jumped in at some point during
the execution of 'a' and reset 'thing' back to 0.
-- 
  Uri

Please consider the environment before printing this message.
http://wwf.panda.org/savepaper/

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to