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')) print(r.llen('new'))
data = r.rpop('new') data = r.rpop('new')
if data is not None and len(data) > 0: if data is not None and len(data) > 0:
print(len(data))
now = time.time() now = time.time()
end = now + wait_time end = now + wait_time
a = bytes([ord('*')]) + bytearray(data) + bytes([ord('#')]) a = bytes([ord('*')]) + bytearray(data) + bytes([ord('#')])

View File

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