Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'called.': 0.09; 'from:addr:pitrou.net': 0.09; 'from:addr:solipsis': 0.09; 'lost.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'atexit': 0.16; 'buffering': 0.16; 'from:name:antoine pitrou': 0.16; 'message- id:@post.gmane.org': 0.16; 'received:213.41.240': 0.16; 'received:213.41.240.54': 0.16; 'received:charlus.yi.org': 0.16; 'received:yi.org': 0.16; "user's": 0.18; 'mechanism': 0.19; 'correct,': 0.23; 'fine': 0.24; 'writes:': 0.25; 'problem': 0.29; 'objects': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'object': 0.33; 'file': 0.34; 'header:X-Complaints-To:1': 0.34; 'eric': 0.34; '(including': 0.34; 'calling': 0.34; 'problem.': 0.35; 'to:addr:python-list': 0.35; 'something': 0.35; 'received:org': 0.36; 'run': 0.37; 'hello,': 0.37; 'charset:us- ascii': 0.37; 'problems': 0.38; 'called': 0.40; 'to:addr:python.org': 0.40; 'opened': 0.64 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Antoine Pitrou Subject: Re: nested embedding of interpreter Date: Mon, 6 Feb 2012 19:59:24 +0000 (UTC) References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 213.41.240.54 (Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1328558381 news.xs4all.nl 6966 [2001:888:2000:d::a6]:46102 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19907 Hello, Eric Frederich gmail.com> writes: > > 1)Is calling Py_Initialize twice correct, or will I run into other problems > down the road? It's fine in practice (spurious calls are ignored). > I am not sure if there is a mechanism to get something called at the end of the > user's session with the program though, so is it a problem if I don't call > Py_Finalize at the end? Yes, it's a problem. If you don't call Py_Finalize, atexit handlers, object destructors and the like will not be called. These include destructors of file objects (including stdout): any buffering in a still-open file opened for writing can be lost. Regards Antoine.