Using "pickle" for interprocess communication - some notes and things that ought to be documented.

John Nagle nagle at animats.com
Fri Jan 18 12:54:46 EST 2008


John Nagle wrote:
> Irmen de Jong wrote:
>> Christian Heimes wrote:
>>> John Nagle wrote:
>>>> It's possible to use "pickle" for interprocess communication over
>>>> pipes, but it's not straightforward.

    Another "gotcha".  The "pickle" module seems to be OK with the
translations of "universal newlines" on Windows, but the "cPickle" module
is not.  If I pickle

	Exception("Test")

send it across the Windows pipe to the parent in universal newlines
mode, and read it with cPickle's

	load()

function, I get

	ImportError: No module named exceptions

If I read it with "pickle"'s "load()", it works.  And if I read the input
one character at a time until I see ".", then feed that to cPickle's "loads()",
that works.  So cPickle doesn't read the same thing Python does in "universal
newline" mode.

Is there any way within Python to get the pipe from a child process to the
parent to be completely transparent under Windows?

				John Nagle



More information about the Python-list mailing list