[python-win32] Passing an object to a process

Preston Landers planders at gmail.com
Wed Mar 14 20:20:07 CET 2012


Without getting into too philosophical of a discussion, the only sense
in which objects can truly move from one process to another is
recreating them in the other process.  Even fork() makes copies of
everything.

Have you tried pickle or other techniques of serialization? Not sure
offhand if the logger module supports pickle but it might.

You can always just create a new logger object using the same
parameters as the original (filename, etc), right? Or am I missing
something?

There IS a way to get filehandles to be shared by a child process.
But do you even need to do that if you can just recreate a new logger
object?

regards,
Preston


On Wed, Mar 14, 2012 at 1:53 PM, Tony Cappellini <cappy2112 at gmail.com> wrote:
>
> On Windows XP - I've got a program running which has spawned a process using
> os.spawnv().
>
> My program has a logger object instantiated that I want to pass to the
> process that was spawned.
> I need to log errors seen by the process, to the same logfile that the
> program uses for logging.
>
> I have the handle, thread ID, and process id of the process, but I see no
> way to share the logger object using these values.
>
> How can I pass a logger instance to the process, from the program which
> spawned the process?
>
> For legacy compatibility reasons, I'm stuck with an older version of Python
> that doesn't have the subprocess module and other features that are
> available with more modern releases of Python.
>
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>


More information about the python-win32 mailing list