0

I have two different processes.

  1. Generator.py: create some data and dump to disk
  2. Control.py: Control script from where I can call Generator.py using subprocess.

What I am trying to achieve is that Control.py can receive the output of Generator.py without dumping it output to disk. I want to establish communication in such a way that Control.py can get data in memory from Generator.py.

Scenario is this:

Generator.py
def foo():
    myList = [1,2,3]
    return myList 

foo()

Control.py:
handleA = subprocess.Popen(["python",  "Generator.py"])

My Objective is to avial myList in Control.py. In this case how can I do this ? I was planning to use multiprocessing.Queue but question is how to share Queue object with Generator.py through subprocess ?

What is best way to achieve this ?

Amit Sharma
  • 1,987
  • 2
  • 18
  • 29
  • 1
    Possible duplicate of [Shared memory in multiprocessing](https://stackoverflow.com/questions/14124588/shared-memory-in-multiprocessing) – Vlad May 08 '18 at 05:15
  • I have two separate programs and no common function, how to share data produced from Generator.py to Control.py – Amit Sharma May 08 '18 at 07:55
  • why you launch it with subprocess can you use python process https://docs.python.org/3.4/library/multiprocessing.html?highlight=process because both of it is a python script. Because if you use process (not subprocess) you can use the queue interface to share the state with the two process – Hamuel May 08 '18 at 08:13
  • Do you mean I should add call in Generator.py as `Process(target=foo, args=(q,))` but how Control.py will get the data I will put in Generator.py ? – Amit Sharma May 08 '18 at 08:28

0 Answers0