Example #1
0
def mon_process(index) :
    print 'pid: %s, index: %s' % (os.getpid(), index)

    q = Queue.Queue()
    # result_map = {}

    # for cell in cells_of_region(index) : print cell

    # thr_worker = print_cell
    thr_worker = ping_cell
    [threading.Thread(target = child_thread, args = (q, thr_worker)).start() for i in xrange(num_thread_region)]

    while True :
        result_map.clear()
        map(lambda thr_index : q.put(thr_index), thr_indice(index))
        q.join()
        # print result_map
        send_process_result((index, result_map))
        time.sleep(sleep_time)
Example #2
0
def control_process( region_index, pipe_conn, shared_matrix):
    
    #print 'pid: %s, index: %s' % (os.getpid(), region_index)
   
    global subproc_matrix
    subproc_matrix = shared_matrix
    
    #print_matrix(subproc_matrix)
    
    q = Queue.Queue()

    [threading.Thread(target = child_thread, args = (q, do_control_job)).start() for i in xrange(num_thread_region)]
    
    while True :
        msg = pipe_conn.recv() #wait for signal from pipe

        #print "Worker process: " + str(region_index) + " "+ msg

        map(lambda thr_index : q.put(thr_index), thr_indice(region_index))
        q.join()
        #print "Worker process: " + str(region_index) + " Done!"
        pipe_conn.send("Worker process: " + str(region_index) + " Done!")