import time from multiprocessing import Process Pipe def conn while if

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import time
from multiprocessing import Process, Pipe
def f(conn):
while 1:
if conn.poll(1):
conn.send(time.time())
conn.close()
parent_conn, child_conn = Pipe()
p = Process(target=f, args=(child_conn,))
p.start()
startTime = time.time()
parent_conn.send('123456789')
while 1:
a = parent_conn.recv()
if a != None:
print time.time() - a
break break