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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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