forked from tmbdev/clstm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplay_server.py
More file actions
36 lines (33 loc) · 819 Bytes
/
display_server.py
File metadata and controls
36 lines (33 loc) · 819 Bytes
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
import os
import numpy
from pylab import *
import traceback
import zmq
context = zmq.Context()
socket = context.socket(zmq.REP)
addr = os.environ.get("PYSERVER","tcp://127.0.0.1:9876")
socket.bind(addr)
poller = zmq.Poller()
poller.register(socket, zmq.POLLIN)
def farg(index):
global args
return numpy.fromstring(args[index],dtype=float32)
def farg2(index,d0,d1):
global args
return numpy.fromstring(args[index],dtype=float32).reshape(d0,d1)
while True:
while True:
evts = poller.poll(100)
if evts!=[]: break
ginput(1,0.01)
args = socket.recv_multipart()
print "----------------"
print args[0]
result = None
try:
exec args[0]
except Exception,e:
print "FAILED"
traceback.print_exc()
draw()
socket.send(str(result))