[python-win32] Passing an object to a process

Tony Cappellini cappy2112 at gmail.com
Wed Mar 14 20:55:21 CET 2012


> >>in which objects can truly move from one process to another is
> >>recreating them in the other process.  Even fork() makes copies of
> everything.
>
Recreating an object in another process means it's a different object, not
a shared one.


>
> >>Have you tried pickle or other techniques of serialization? Not sure
> >>offhand if the logger module supports pickle but it might.
>
Yes. I've just tried this, even though I expected it not to work.

If process A pickles a logger object, and process B unpickles it,
referencing of an object in a different process is meaningless.

In my case, when the process attempted to write to the logger, no entries
were seen in the logfile. Surprisingly, no exceptions occurred- but this
could just be a coincidence.

>>You can always just create a new logger object using the same
> >>parameters as the original (filename, etc), right?

>>Or am I missing something?
>

That may work, and with less effort than my original idea.

But if two processes write to the logfile at the same time (especially on a
multicore machine),
hard-to-read logfiles may result.
it's worth a try.

It would be great if the process could pass the info to be written to the
logfile,
back to its creator and let the creator do all the writing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20120314/a3fe1d66/attachment.html>


More information about the python-win32 mailing list