messing around

master
Raphaël Vinot 2015-03-21 20:34:56 +01:00
parent 9da3123796
commit 3ee6e5332b
2 changed files with 8 additions and 0 deletions

View File

@ -25,6 +25,7 @@ def send(r, s):
print(r.llen('new'))
data = r.rpop('new')
if data is not None and len(data) > 0:
print(len(data))
now = time.time()
end = now + wait_time
a = bytes([ord('*')]) + bytearray(data) + bytes([ord('#')])

View File

@ -2,6 +2,7 @@
import socketserver
import redis
import time
class MyTCPHandler(socketserver.BaseRequestHandler):
@ -56,11 +57,17 @@ class MyTCPHandler(socketserver.BaseRequestHandler):
print(reason)
return None
print('Start receiving from {}...'.format(self.client_address[0]))
got_one_frame = False
while True:
data = self.request.recv(self.imgsize)
self.r.lpush('new', data)
if len(data) == 0:
if not got_one_frame:
time.sleep(1)
continue
break
else:
got_one_frame = True
print('... Done with {}.'.format(self.client_address[0]))