Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31251
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.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.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '(of': 0.07; 'imported': 0.09; 'thread,': 0.09; 'thread': 0.11; 'do,': 0.15; 'accesses': 0.16; 'dictionary.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oct': 0.16; 'sure.': 0.16; 'later': 0.16; 'wrote:': 0.17; 'module,': 0.17; 'replacing': 0.17; 'variables': 0.17; 'module': 0.19; 'import': 0.21; 'received:209.85.214.174': 0.21; 'class.': 0.23; 'second': 0.24; 'external': 0.24; 'header:In-Reply-To:1': 0.25; 'setting': 0.26; '(as': 0.27; 'replace': 0.27; 'message-id:@mail.gmail.com': 0.27; 'skip:_ 10': 0.29; 'checks': 0.30; 'system,': 0.32; 'good.': 0.32; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'doing': 0.35; 'pm,': 0.35; 'subject:?': 0.35; "won't": 0.35; 'received:209.85': 0.35; 'something': 0.35; 'but': 0.36; 'modules': 0.36; 'should': 0.36; 'received:209': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; 'think': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'first': 0.61; '(that': 0.62; 'different': 0.63; 'state.': 0.71 |
| 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=bnDygxN6yEddyjahD/oCz5u0heNbNilc6Zh8v29Ir1E=; b=M37o6q756czGnXWKrIg8btD/gIZYVCYtYL305S8Z/QU+PURSwaotHjlRnE04pOZFEe 9K6Er9Pm7aXxtczMI8HPFJhJpRb+pCcxWRHvb85aNwsDLQWD5Ft+v+AIet2Uc+KKDHGu E5c7zDBugb4kD1Jxct0JSBgyOc0IBYSo53CbLUFrG0bVGd3Ai9IiPN1RnxHOXtmd5eys 7texp/uaw9BVe+cmPc4L5P0afFPymFd4b+tl5AS+yUOYCVU4cG13oK6Wf+sgAoKjwfht GWcHSJr3AZq1X1rLo5c7sORcRp2jnaEnKC4leOf9uPVvrM8lGCS0/py5uDQrHwfP+nCH 3ltQ== |
| MIME-Version | 1.0 |
| In-Reply-To | <CAAj3U_AhyqLaCFNX8QbnkiY0pPec15BPxZr5DJ2bbKmgZ8PYUQ@mail.gmail.com> |
| References | <CAAj3U_Ce+F6u+mhUy+_3uNXp4ck2QXtUw+7VG4wo9H88hJs0pQ@mail.gmail.com> <50772BEA.309@davea.name> <CAAj3U_AhyqLaCFNX8QbnkiY0pPec15BPxZr5DJ2bbKmgZ8PYUQ@mail.gmail.com> |
| Date | Mon, 15 Oct 2012 01:01:21 +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.2176.1350223284.27098.python-list@python.org> (permalink) |
| Lines | 19 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350223284 news.xs4all.nl 6872 [2001:888:2000:d::a6]:58128 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31251 |
Show key headers only | View raw
On Sun, Oct 14, 2012 at 9:36 PM, Juergen Bartholomae <bartholomae.juergen@googlemail.com> wrote: > Unfortunately, replacing __builtins__ at import time won't do, because > external modules (that is, .py) get imported only once when they are > accessed by the first thread, which includes (of course) setting up of > __dict__ and __builtins__. When a second thread later accesses this > module, it has the same variables in __builtins__ that were added by > the same module in first thread Sure. But if they're using __builtins__ by name, then you can simply replace that with something that checks a thread id and responds with that thread's dictionary. There's no particular reason for __builtins__ to be a module (as far as I know!), so you should be able to replace it with an object of your own class. I think DaveA's recommendation is good. Make a "Version 2.0" of your system, with a different way of doing global state. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: __builtins__ thread-safe / __builtins__ as function? Chris Angelico <rosuav@gmail.com> - 2012-10-15 01:01 +1100
csiph-web