Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81412

Re: unloading a module created with imp.new_module

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'interpreter': 0.05; 'output': 0.05; 'class,': 0.07; 'subject:module': 0.09; '.py': 0.16; '23,': 0.16; '__del__': 0.16; 'garbage': 0.16; 'globals': 0.16; "module's": 0.16; 'subject:created': 0.16; 'wrote:': 0.18; 'module': 0.19; 'email addr:gmail.com&gt;': 0.22; 'instance,': 0.24; 'file.': 0.24; '&gt;': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'subject:skip:i 10': 0.31; 'class': 0.32; 'run': 0.32; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'being': 0.38; 'skip:& 10': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'back': 0.62; 'skip:\xe2 10': 0.65; 'here': 0.66; 'between': 0.67; 'dict,': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=pngI6Z9fSWDc8WYOdh5UQikmtY9s1MT7y/cSBHP5J80=; b=SnC+GEYa22vEryyb8Z0AIKwxdtcVqA4bHkzvK32OjHW+R/pNOFz9rtsxsIqq3kUizS JgYhxOj7aE6dBQAnjl8IjZ45rpZ9k7DlA7ZTQ+V6JUjPAyGE0i7fECqNGW9Y2ow0ZQo7 wmRbkoRFwrdgpaXv6X0iHCxWa0Pp4vmmo2c74/5J1bmcepK3CodmODRNBHAA3l2zus+g sfh/wUDw1p80pKY5T6ippDXEVR2TdwjABs6KYiSrquZQPpKS8ZGfdWPlsffwPpDjTAO3 T+yCHZqK8t08EVN5LvtHWW1AcRC/xSJ7qrIL81TuJd4XkFMIREd7cFt/jKutNCRfyeee sHcA==
MIME-Version 1.0
X-Received by 10.68.111.161 with SMTP id ij1mr28369730pbb.10.1416792434858; Sun, 23 Nov 2014 17:27:14 -0800 (PST)
In-Reply-To <B8391E6B-5AA4-4125-96BC-74B12B46E927@gmail.com>
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 Sun, 23 Nov 2014 18:27:14 -0700
Subject Re: unloading a module created with imp.new_module
From Ian Kelly <ian.g.kelly@gmail.com>
To Python <python-list@python.org>
Content-Type multipart/alternative; boundary=047d7b5db7facce0ae050890b1be
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16215.1416792444.18130.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416792444 news.xs4all.nl 2924 [2001:888:2000:d::a6]:50457
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81412

Show key headers only | View raw


[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


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