-
Notifications
You must be signed in to change notification settings - Fork 0
/
sender2.py
52 lines (39 loc) · 1.02 KB
/
sender2.py
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
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding: utf-8 -*-
"""
Created on Mon Sep 2 17:25:50 2013
@author: rossi
"""
from multiprocessing.connection import Client
from multiprocessing import Process,Pipe
from scipy import *
import pickle
import thread
#import threading
def waiting():
print 'waiting...'
conn = None
def TryToConnect(child):
address = ('jeremyfisher.math.udel.edu', 6000)
#address = ('nutkin', 6000)
conn = Client(address, authkey='secret password')
# conn.send('hi')
x = r_[0.1:0.5:10j]
conn.send(pickle.dumps(x))
conn.send('close')
# can also send arbitrary objects:
# conn.send(['a', 2.5, None, int, sum])
conn.close()
child.send('All done')
#timer = threading.Timer(10.0, waiting)
#timer = threading.Timer(10.0,thread.interrupt_main)
parent_conn,child_conn = Pipe()
proc = Process(target=TryToConnect,args=(child_conn,))
proc.start()
waitingcount = 0
while (not parent_conn.poll()):
waitingcount += 1
parent_conn.recv()
print "Success"
print waitingcount
#timer.start()
#ConnectSuccess = False