Multi-processing... Running 2 scripts on 2 terminals
<p>I have 2 scripts that start multiple processes. Right now I'm opening up two different terminals and running python start.py to start both the scripts. How can I achieve this with one command, or one running one script.</p>

<p>Start.py 1</p>

<pre><code># globals
my_queue = multiprocessing.Manager().Queue() # queue to store our values
stop_event = multiprocessing.Event() # flag which signals processes to stop
my_pool = None

def my_function(foo):
    print("starting %s" % foo)
    try:
        addnews.varfoo)
    except Exception,e: 
        print str(e)

MAX_PROCESSES = 50
my_pool = multiprocessing.Pool(MAX_PROCESSES)

x = Var.objects.order_by('name').values('link')
for t in x:
    t = t.values()[0]
    my_pool.apply_async(my_function, args=(t,))
my_pool.close()
my_pool.join()
</code></pre>

<p>Start1.py 2</p>

<pre><code># globals
MAX_PROCESSES = 50
my_queue = multiprocessing.Manager().Queue() # queue to store our values
stop_event = multiprocessing.Event() # flag which signals processes to stop
my_pool = None

def my_function(var):
   var.run_main(var)
   stop_event.set()


def var_scanner():
    # Since `t` could have unlimited size we'll put all `t` value in queue 
    while not stop_event.is_set(): # forever scan `values` for new items
    y = Var.objects.order_by('foo).values('foo__foo')
    for t in y:
        t = t.values()[0]
        my_queue.put(t)

try:
    var_scanner_process = multiprocessing.Process(target=var_scanner)
    var_scanner_process.start()
    my_pool = multiprocessing.Pool(MAX_PROCESSES)

    #while not stop_event.is_set():
    try: #  if queue isn't empty, get value from queue and create new process
        var = my_queue.get_nowait() # getting value from queue
        p = multiprocessing.Process(target=my_function, args=(var,))
        p.start()
    except Queue.Empty:
        print "No more items in queue"
        time.sleep(1) 
        #stop_event.set()

except KeyboardInterrupt as stop_test_exception:
     print(" CTRL+C pressed. Stopping test....")
     stop_event.set()
</code></pre>