Multithreading Embedded C/Python : Giving each thread its own sys.stdout

Warren Postma embed at NOSPAM.geocities.com
Tue Jun 27 10:12:26 EDT 2000


Okay, here's a simpler twist on the previous EMAIL:

How do you do a deep copy of a module? Ie, if I have two namespaces, and I
import sys into both of them, I am getting two refcounts on the SAME object,
and modifying ONE will modify both. I really want a deep copy of a module.

Unfortunately, according to the documents, you can't deep-copy a module.
How about making something that looks like a copy of sys but isn't truly a
module.  Perhaps a class containing the same objects as the module sys would
have contained. Then the main thread can have the module sys, and the rest
of the threads can have a pseudo-sys, one that could tell them what thread
context and namespace they are in, as well as having it's own version of
sys.stdout.

Warren







More information about the Python-list mailing list