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


Groups > comp.lang.python > #80715

Re: Help with Python Multiprocessing

Newsgroups comp.lang.python
Date 2014-11-13 15:21 -0800
References <91fd5810-6a2a-46d8-8d1e-b68afced3987@googlegroups.com> <mailman.15785.1415906534.18130.python-list@python.org>
Message-ID <23bdb9b9-1d9b-4edf-9c38-9165f17ca62f@googlegroups.com> (permalink)
Subject Re: Help with Python Multiprocessing
From Anurag <anuragpatibandla7@gmail.com>

Show all headers | View raw


On Thursday, November 13, 2014 2:22:29 PM UTC-5, Gary Herron wrote:
> On 11/13/2014 10:07 AM, Anurag wrote:
> > I am having trouble understanding the Multiprocessing module.
> > I need to run three different files 'Worker1' , 'Worker2', 'Worker3' all at once. Currently I am doing this :
> >
> > from multiprocessing import Process
> >
> > import Worker1.py
> > import Worker2.py
> > import Worker3.py
> >
> >
> >
> > p1 = Process(target=Worker1.py)
> > p1.start()
> > p2 = Process(target=Worker2.py)
> > p2.start()
> > p3 = Process(target=Worker3.py)
> > p3.start()
> >
> > But this will only start the 'Worker1'. How do I execute all the three files at once?
> >
> > Thanks
> 
> I doubt that is your actual code.  Python imports do not include .py 
> extension.  Please show us your actual code.  (Use cut and paste 
> please.)  And then take the time to tell us how you determine only the 
> first is started.  Then we can probably help.
> 
> As an aside: To be sure, one could make the above imports work by having 
> files named py.py and __init__.py in a directory named Worker1 (and the 
> same for directories Worker2 and Worker3).   I think it's more likely 
> that you miss-typed the above code.
> 
> Gary Herron

That is the actual code I am using in a file named 'ex.py'. 
My Worker files are also named with a '.py' extension.
When I run my 'ex.py' through a command prompt, the 'Worker1.py' is executed in the same command prompt and starts an infinite loop. It never gets to the 'Worker2.py' part.
But I want my Workers to be executed in different command prompts.

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


Thread

Help with Python Multiprocessing Anurag <anuragpatibandla7@gmail.com> - 2014-11-13 10:07 -0800
  Re: Help with Python Multiprocessing Anurag <anuragpatibandla7@gmail.com> - 2014-11-13 10:10 -0800
    Re: Help with Python Multiprocessing MRAB <python@mrabarnett.plus.com> - 2014-11-13 18:45 +0000
  Re: Help with Python Multiprocessing sohcahtoa82@gmail.com - 2014-11-13 11:18 -0800
    Re: Help with Python Multiprocessing Anurag <anuragpatibandla7@gmail.com> - 2014-11-13 15:22 -0800
      Re: Help with Python Multiprocessing sohcahtoa82@gmail.com - 2014-11-14 11:41 -0800
  Re: Help with Python Multiprocessing Gary Herron <gary.herron@islandtraining.com> - 2014-11-13 11:12 -0800
    Re: Help with Python Multiprocessing Anurag <anuragpatibandla7@gmail.com> - 2014-11-13 15:21 -0800
  Re: Help with Python Multiprocessing Anurag <anuragpatibandla7@gmail.com> - 2014-11-23 12:56 -0800
    Re: Help with Python Multiprocessing sohcahtoa82@gmail.com - 2014-11-24 12:58 -0800

csiph-web