Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.134 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.73; '*S*': 0.00; 'interpreter': 0.05; 'amounts': 0.07; 'method.': 0.07; 'boundaries.': 0.09; 'python': 0.11; 'thread': 0.14; 'accident.': 0.16; 'evaluating': 0.16; 'guessing': 0.16; 'subclasses': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'possible,': 0.19; 'memory': 0.22; 'header:User-Agent:1': 0.23; 'example.': 0.24; 'fairly': 0.24; 'cheers,': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'ideal': 0.29; 'scale': 0.29; "doesn't": 0.30; 'code': 0.31; 'object.': 0.31; 'class': 0.32; 'critical': 0.32; 'run': 0.32; 'entirely': 0.33; 'skip:_ 10': 0.34; 'could': 0.34; 'received:66': 0.35; 'something': 0.35; 'objects': 0.35; 'interaction': 0.36; 'thanks': 0.36; 'so,': 0.37; 'too': 0.37; 'clear': 0.37; 'starting': 0.37; 'minimum': 0.38; 'skip:o 20': 0.38; 'problems': 0.38; 'e.g.': 0.38; 'to:addr:python-list': 0.38; 'resource': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'enough': 0.39; 'how': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'easy': 0.60; 'chain': 0.60; 'first': 0.61; "you'll": 0.62; 'protection': 0.63; 'kind': 0.63; 'such': 0.63; 'happen': 0.63; 'between': 0.67; 'sound': 0.68; 'potentially': 0.81; 'bare': 0.84; 'gregory,': 0.84; 'interaction.': 0.84; 'interference': 0.84; "it'd": 0.84; 'difficult,': 0.91; 'trouble.': 0.91; 'hands': 0.96 Date: Sat, 07 Dec 2013 11:01:37 +1030 From: Garthy User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Embedding multiple interpreters References: <52A183F8.7000807@entropicsoftware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386376302 news.xs4all.nl 2910 [2001:888:2000:d::a6]:58436 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61202 Hi Gregory, On 07/12/13 08:53, Gregory Ewing wrote: > Garthy wrote: >> The bare minimum would be protection against inadvertent interaction. >> Better yet would be a setup that made such interaction annoyingly >> difficult, and the ideal would be where it was impossible to interfere. > > To give you an idea of the kind of interference that's > possible, consider: > > 1) You can find all the subclasses of a given class > object using its __subclasses__() method. > > 2) Every class ultimately derives from class object. > > 3) All built-in class objects are shared between > interpreters. > > So, starting from object.__subclasses__(), code in any > interpreter could find any class defined by any other > interpreter and mutate it. Many thanks for the excellent example. It was not clear to me how readily such a small and critical bit of shared state could potentially be abused across interpreter boundaries. I am guessing this would be the first in a chain of potential problems I may run into. > This is not something that is likely to happen by > accident. Whether it's "annoyingly difficult" enough > is something you'll have to decide. I think it'd fall under "protection against inadvertent modification"- down the scale somewhat. It doesn't sound like it would be too difficult to achieve if the author was so inclined. > Also keep in mind that it's fairly easy for Python > code to chew up large amounts of memory and/or CPU > time in an uninterruptible way, e.g. by > evaluating 5**100000000. So even a thread that's > keeping its hands entirely to itself can still > cause trouble. Thanks for the tip. The potential for deliberate resource exhaustion is unfortunately something that I am likely going to have to put up with in order to keep things in the same process. Cheers, Garth