Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #81412
| References | <C093BC09-3AB7-49DB-B160-265A34C6BCDA@gmail.com> <CALwzidnHV8smFHtvixtdhX-i94PWbwNKSRrR6HAfhn2HOKqxsw@mail.gmail.com> <CALwzid=9Zgu3svDP-mv8-1DrZkKkDcNTxy+D=obwGsOGzB5aZQ@mail.gmail.com> <B8391E6B-5AA4-4125-96BC-74B12B46E927@gmail.com> |
|---|---|
| Date | 2014-11-23 18:27 -0700 |
| Subject | Re: unloading a module created with imp.new_module |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16215.1416792444.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On Nov 23, 2014 4:10 AM, "Patrick Stinson" <patrickkidd@gmail.com> wrote:
> m = types.ModuleType('mine')
> exec(s, m.__dict__)
> print('deleting...')
> m = None
> print('done')
>
> and the output is:
>
> deleting...
> done
> __del__
>
> I the “__del__" to come between “deleting…” and “done”. This is not being
run from the interactive interpreter by via a .py file.
This suggests the presence of a reference cycle, since the object is
deleted afterward by the garbage collector. One cycle here is that the
__del__ function has a reference to the module's globals dict, which has a
reference to the class instance, which has a reference to the class, which
has a reference back to the function. There may be other cycles here as
well, but it may also be that the module object itself isn't part of them.
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: unloading a module created with imp.new_module Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-23 18:27 -0700
csiph-web