Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #68703

Re: Implement multiprocessing without inheriting parent file handle

From Mark H Harris <harrismh777@gmail.com>
Newsgroups comp.lang.python
Subject Re: Implement multiprocessing without inheriting parent file handle
Date 2014-03-21 12:25 -0500
Organization Aioe.org NNTP Server
Message-ID <lghsmd$3as$1@speranza.aioe.org> (permalink)
References <mailman.8363.1395415712.18130.python-list@python.org>

Show all headers | View raw


On 3/21/14 10:28 AM, Antony Joseph wrote:
> How can i implement multiprocessing without inherit file descriptors
> from my parent process?

I'll bite...

If what you mean by 'multiprocessing' is forking a process, to get a 
child process, which will then do some parallel processing for some 
reason, the answer is two-fold: 1) you can't, and 2) you might try using 
threads.  (there are other answers too)

When you fork a process the only differences between the child and the 
parent is 1) process number, and 2) one is the 'parent' and one is the 
'child'.  They are 'exact' copies of one another.

In socket daemons the parent always listens on a given port, then forks 
a child process to establish a secondary port(s) to handle the comm 
link;  at that point (instant) both the parent and the child ask a 
simple question, "Am I the parent?"  If so, the code goes back to 
listening... if not, the code (the child) establishes the necessary comm 
ports and handles the server request.  When finished the child notifies 
the parent and ends.

You can try parent/child arrangements (maybe use rpc, or shared memory 
segments for inter process comm), or you might try threads... which are 
a separate unit of execution (not a full process copy) but with access 
to the parent's memory.

Otherwise, you might want to tell the list some of the background of 
your difficulty, or put the difficulty in pythonic terms, or simply ask 
your python related question with as much simplified but complete detail 
as possible.

Is there a python question in there someplace?

marcus

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Implement multiprocessing without inheriting parent file handle Antony Joseph <antonyjoseph89@gmail.com> - 2014-03-21 20:58 +0530
  Re: Implement multiprocessing without inheriting parent file handle Mark H Harris <harrismh777@gmail.com> - 2014-03-21 12:25 -0500
  Re: Implement multiprocessing without inheriting parent file handle Grant Edwards <invalid@invalid.invalid> - 2014-03-21 17:37 +0000
  Re: Implement multiprocessing without inheriting parent file handle Marko Rauhamaa <marko@pacujo.net> - 2014-03-21 19:42 +0200
    Re: Implement multiprocessing without inheriting parent file handle Mark H Harris <harrismh777@gmail.com> - 2014-03-21 13:16 -0500
      Re: Implement multiprocessing without inheriting parent file handle Chris Angelico <rosuav@gmail.com> - 2014-03-22 09:50 +1100

csiph-web