Garbage collection problem with generators
guohaochuan at gmail.com
Wed Dec 28 08:14:45 EST 2016
Sorry about breaking the rule.
I'm just curios about this problem. And I'm using this workaround to prevent
redundant resource creation.
On Wed, Dec 28, 2016 at 9:12 PM Chris Angelico <rosuav at gmail.com> wrote:
> On Wed, Dec 28, 2016 at 9:03 PM, Haochuan Guo <guohaochuan at gmail.com>
> > Anyone? The script to reproduce this problem is in:
> > https://gist.github.com/wooparadog/766f8007d4ef1227f283f1b040f102ef
> > On Fri, Dec 23, 2016 at 8:39 PM Haochuan Guo <guohaochuan at gmail.com>
> >> This is reproducible with python2.7, but not in python3.5. I've also
> >> with `thread` instead of `gevent`, it still happens. I'm guessing it's
> >> related to garbage collection of generators.
> >> Did I bump into a python2 bug? Or am I simply wrong about the way to
> >> generators...?
> (Please don't top-post.)
> Maybe the fix is to just use Python 3.5+? :) It probably is to do with
> the garbage collection of generators; so you may want to consider
> using something very explicit (eg a context manager) to ensure that
> you call gen.close().
More information about the Python-list