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


Groups > comp.lang.python > #81442

Re: unloading a module created with imp.new_module

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <patrickkidd@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'interpreter': 0.05; 'output': 0.05; 'class,': 0.07; 'subject:module': 0.09; 'cc:addr :python-list': 0.11; '.py': 0.16; '23,': 0.16; '__del__': 0.16; 'function?': 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; 'cc:addr:python.org': 0.22; 'print': 0.22; 'instance,': 0.24; 'file.': 0.24; 'cc:2**0': 0.24; '&gt;': 0.26; 'references': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'url:mailman': 0.30; 'subject:skip:i 10': 0.31; 'class': 0.32; 'run': 0.32; 'url:python': 0.33; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'done': 0.36; 'url:listinfo': 0.36; 'method': 0.36; 'url:org': 0.36; 'being': 0.38; 'message-id:@gmail.com': 0.38; 'nov': 0.38; 'pm,': 0.38; 'does': 0.39; 'itself': 0.39; 'skip:p 20': 0.39; 'url:mail': 0.40; 'how': 0.40; 'ian': 0.60; 'back': 0.62; 'header:Message-Id:1': 0.63; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; 'here': 0.66; 'between': 0.67; '2014,': 0.84; 'beside': 0.84; 'dict,': 0.84; 'comfort': 0.96
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=eQh0+B9NrbwhnTSkKbRvI+cj0NVTFRagmRaI3hbJm0A=; b=PrH/2mNYCRcGzuQ6hZ/j2ZS50NrVJlRWkW4hjh0B0P1h835e7fTIHbd8Rt6zB9Jw9Y 03ckT9AuHg6NwFOruEEcOJyITLmEJHUUQuoveLmN/cDDUBDt5qcce8JJsLdKsCxCV4hB YQ+kVBamtRWzDuNwjGAqdJCG/QZN2WZXl/W0suOPn+LFrcGD7MbjS5l27NSDucrraqlS 3T9GgO4uI6LIfgoO+UkP+GGmlqMpNZ0pdZppGtRB4XYD2aO1DqAH6kqSKa58ZFke+aU8 HFCU7A+pRj1VLmet+8qIRGqp9CiWC4LkGoRSosxxg7Ds4pl9hFL7RCbh1oU2kmM9fzcM k7ag==
X-Received by 10.70.36.15 with SMTP id m15mr30713985pdj.132.1416814038207; Sun, 23 Nov 2014 23:27:18 -0800 (PST)
Content-Type multipart/alternative; boundary="Apple-Mail=_425D012F-63AF-4AD3-B5F2-35BFC73C768E"
Mime-Version 1.0 (Mac OS X Mail 8.1 \(1993\))
Subject Re: unloading a module created with imp.new_module
From Patrick Stinson <patrickkidd@gmail.com>
In-Reply-To <CALwzidkgysWb0o=NG-McQpss+7B1o2AsECMzio=75eCxDuh_HQ@mail.gmail.com>
Date Sun, 23 Nov 2014 22:27:16 -0900
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> <CALwzidkgysWb0o=NG-McQpss+7B1o2AsECMzio=75eCxDuh_HQ@mail.gmail.com>
To Ian Kelly <ian.g.kelly@gmail.com>
X-Mailer Apple Mail (2.1993)
X-Mailman-Approved-At Mon, 24 Nov 2014 09:16:01 +0100
Cc Python <python-list@python.org>
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.16237.1416816962.18130.python-list@python.org> (permalink)
Lines 98
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416816962 news.xs4all.nl 2874 [2001:888:2000:d::a6]:57334
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81442

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

How does the __del__ method have a reference to the module’s globals dict? because it references the print function?

Crazy. Is there any other way to comfort when a module is being deleted beside defining a class object with a printing dtor?


> On Nov 23, 2014, at 4:27 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> 
> 
> On Nov 23, 2014 4:10 AM, "Patrick Stinson" <patrickkidd@gmail.com <mailto: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.
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: unloading a module created with imp.new_module Patrick Stinson <patrickkidd@gmail.com> - 2014-11-23 22:27 -0900

csiph-web