messing around
parent
9da3123796
commit
3ee6e5332b
|
@ -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('#')])
|
||||||
|
|
|
@ -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]))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue