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


Groups > comp.lang.python > #31121

Re: __builtins__ thread-safe / __builtins__ as function?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.010
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'assign': 0.07; 'level,': 0.07; 'referring': 0.07; 'thread': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oct': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'module': 0.19; 'import': 0.21; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; '(such': 0.27; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'dictionary': 0.29; 'normal.': 0.29; 'fri,': 0.30; 'function': 0.30; 'code': 0.31; 'to:addr :python-list': 0.33; 'received:google.com': 0.34; 'problem,': 0.35; 'subject:?': 0.35; 'received:209.85': 0.35; '12,': 0.36; 'possible': 0.37; 'does': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'different': 0.63
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=WuuHV2qpxorlK0Awvor/Zvf/7xcPop3fKgre104cRr8=; b=gjW9WxKWkNi4dr5dD0UU787qN3VyAKwkqMB0SwFJDnCNrNkmiCIQDyQeu/4Uk7o1M6 P3TAs7enhjhDQde5Q+EeO8c0/gFwVOwEpvTIfTQz2jlXzg9WEp22yLUWbgyth+qoj7/R vEXbMncBKQCG+iJotxX7kzWz3iPjDEQ3zMwt8u+oqUt6pi3/vW28zxauceiVU4k4qgGF TK4hVYcAS5CMtDHsIIpltzuTzYbvcPz5rLApwo36QK+jbWoWqpjpFPW4wbZu3egRT4pg mIArCb1jeUZT6OW4Ihn3dgsFla66K885lE0CvE0fCi7OPE42fY8kM9QejkanTaHwDYC5 6y1A==
MIME-Version 1.0
In-Reply-To <CAAj3U_Ce+F6u+mhUy+_3uNXp4ck2QXtUw+7VG4wo9H88hJs0pQ@mail.gmail.com>
References <CAAj3U_Ce+F6u+mhUy+_3uNXp4ck2QXtUw+7VG4wo9H88hJs0pQ@mail.gmail.com>
Date Fri, 12 Oct 2012 01:25:27 +1100
Subject Re: __builtins__ thread-safe / __builtins__ as function?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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 <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2054.1349965530.27098.python-list@python.org> (permalink)
Lines 14
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1349965530 news.xs4all.nl 6876 [2001:888:2000:d::a6]:40032
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:31121

Show key headers only | View raw


On Fri, Oct 12, 2012 at 1:16 AM, Juergen Bartholomae
<bartholomae.juergen@googlemail.com> wrote:
> One possible solution  is to somehow redirect every __builtins__ to a
> function that returns a different __builtins__ dictionary for each thread
> (such a function already exists).

How exactly does the code reference it? If they're simply referring to
the name __builtins__ at module level, you ought to be able to import
the module, then assign some_module.__builtins__ to your thread-local
object, then call code in it as normal.

An interesting problem, and one where monkeypatching is, imho, justified.

ChrisA

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


Thread

Re: __builtins__ thread-safe / __builtins__ as function? Chris Angelico <rosuav@gmail.com> - 2012-10-12 01:25 +1100

csiph-web