views:

86

answers:

1

Hi,

I am using multiprocessing module, and using pools to start multiple workers. But the file descriptors which are opened at the parent process are closed in the worker processes. I want them to be open..! Is there any way to pass file descriptors to be shared across parent and children?

+3  A: 

There isn't a way that I know of to share file descriptors between processes. If a way exists, it is most likely OS specific.

My guess is that you need to share data on another level.

Mattias Nilsson
Agreed. There are OS-specific ways though.
unbeli
Yeah, I know that fork() for example will duplicate file descriptors, but is there an easy way to do it _after_ the processes have started?
Mattias Nilsson
Yep: http://stackoverflow.com/questions/909064/portable-way-to-pass-file-descriptor-between-different-processes
Rakis
Cool, I didn't know about that.
Mattias Nilsson