Remove old threaded stuff from client
This commit is contained in:
parent
cdb75aa59d
commit
30166f6416
39
client.py
39
client.py
@ -20,52 +20,13 @@ sp = pUp(s)
|
||||
# script start
|
||||
import subprocess
|
||||
import socket
|
||||
import threading
|
||||
import queue
|
||||
|
||||
def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs)
|
||||
|
||||
bufferSize = 8096 # buffer size in bytes
|
||||
queueLengthWait = 10 # How many buffers can be in the queue before waiting for it to empty? 0 for infinite, maxAccumulatedData comes into play. Raise for smoother playback, lower for less delay.
|
||||
maxAccumulatedData = 50*1000*1000 # If queueLengthWait is 0, how much data can be in an outbound thread's queue at maximum before the connection is closed?
|
||||
timeout = 15 # timeout in seconds
|
||||
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
class stdoutThread(threading.Thread):
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self.queue = queue.Queue()
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
data = self.queue.get(timeout=timeout)
|
||||
sys.stdout.buffer.write(data)
|
||||
|
||||
class stdinThread(threading.Thread):
|
||||
def __init__(self,connection):
|
||||
threading.Thread.__init__(self)
|
||||
self.queue = queue.Queue(queueLengthWait)
|
||||
self.connection = connection
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
while True:
|
||||
accumulatedData = self.queue.qsize() * bufferSize
|
||||
|
||||
if queueLengthWait < 1:
|
||||
eprint("Accumulated MB: " +str(accumulatedData/1000000))
|
||||
|
||||
if accumulatedData > maxAccumulatedData:
|
||||
eprint("Accumulated data limit reached. Closing.")
|
||||
self.connection.close()
|
||||
self.queue = False
|
||||
return
|
||||
data = self.queue.get()
|
||||
self.connection.sendall(data)
|
||||
except:
|
||||
self.connection.close()
|
||||
self.queue = False
|
||||
raise
|
||||
|
||||
def listToCommand(lst):
|
||||
cmd = ""
|
||||
|
Loading…
Reference in New Issue
Block a user