On Fri, Jan 25, 2013 at 10:35 AM, Аркадий Левин <poison...@gmail.com> wrote:
> Hi all, i got strange error > > If run this: > > # -*- coding: UTF-8 -*- > > import os > import sys > > from twisted.python import log > from twisted.internet import reactor > from twisted.internet.defer import Deferred, inlineCallbacks > > @inlineCallbacks > def _(): > > try: > (yield Deferred()) > except: > log.err() > > reactor.callLater(0, _) > reactor.run() > > i got exception "GeneratorExit" Why?! > This behavior isn't specific to inlineCallbacks. If you get rid of the reactor usage and the @inlineCallbacks decorator, and just call _().next(), you'll see the same behavior. http://docs.python.org/2.7/reference/expressions.html?highlight=yield%20expression#generator-iterator-methods See the stuff about how .close() throws GeneratorExit into the generator. It is related to garbage collection. When a generator is garbage collected, its .close() method is called. Since you're keeping a reference to the Deferred in the generator itself in the working version, it's not being immediately closed because there's a circular reference. (I think?) -- Christopher Armstrong http://radix.twistedmatrix.com/ http://planet-if.com/
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python