[issue3125] test_multiprocessing causes test_ctypes to fail
report at bugs.python.org
Thu Jun 19 20:01:02 CEST 2008
roudkerk <r.m.oudkerk at gmail.com> added the comment:
> I am not sure to understand. Can you elaborate?
> How is memory management different between windows and unix?
Removing the "if win32" bits will not make shared ctypes objects
picklable on unix. Even on windows there are only picklable in the
context of spawning a child process.
I do not want to encourage people to try to transfer objects which
wrap operating system resources between running processes using
pickling because it is error prone unless done very carefully: one
needs to find some way of "keeping the resource alive" until the
target process gets a chance to unpickle the data. (The source
process must not close its handle to the resource until the target
process obtains its own handle, which may not happen for a long time.)
The simplest way to avoid such problems is to only share such
resources through inheritance. I do add some pickling support to some
types on Windows, but only to emulate the behaviour that Unix gets for
free using fork(). (On Windows trying to transfer objects like locks
or shared ctypes objects over a pipe or queue will, by design, fail
with a RuntimeError)
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list