Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31251 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2012-10-15 01:01 +1100 |
| Last post | 2012-10-15 01:01 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: __builtins__ thread-safe / __builtins__ as function? Chris Angelico <rosuav@gmail.com> - 2012-10-15 01:01 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2012-10-15 01:01 +1100 |
| Subject | Re: __builtins__ thread-safe / __builtins__ as function? |
| Message-ID | <mailman.2176.1350223284.27098.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web