Add queueLengthWait, tweak bufferSize
This commit is contained in:
parent
9b4175dada
commit
d926143913
@ -23,8 +23,9 @@ import socket
|
||||
import threading
|
||||
import queue
|
||||
|
||||
bufferSize = 50000 # buffer size in bytes
|
||||
maxAccumulatedData = 50*1000*1000 # How much data can be in an outbound thread's queue at maximum before the connection is closed?
|
||||
bufferSize = 10000 # buffer size in bytes
|
||||
queueLengthWait = 10 # How many buffers can be in the queue before waiting? 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)
|
||||
|
||||
@ -41,7 +42,7 @@ class stdoutThread(threading.Thread):
|
||||
class stdinThread(threading.Thread):
|
||||
def __init__(self,connection):
|
||||
threading.Thread.__init__(self)
|
||||
self.queue = queue.Queue()
|
||||
self.queue = queue.Queue(queueLengthWait)
|
||||
self.connection = connection
|
||||
|
||||
def run(self):
|
||||
@ -50,7 +51,7 @@ class stdinThread(threading.Thread):
|
||||
accumulatedData = self.queue.qsize() * bufferSize
|
||||
print("Accumulated MB: " +str(accumulatedData/1000000))
|
||||
|
||||
if accumulatedData > maxAccumulatedData:
|
||||
if queueLengthWait < 1 and accumulatedData > maxAccumulatedData:
|
||||
print("Accumulated data limit reached. Closing.")
|
||||
self.connection.close()
|
||||
self.queue = False
|
||||
|
@ -36,7 +36,7 @@ connectionsLock = threading.Lock()
|
||||
serverAddr = ("127.0.0.1",61920)
|
||||
serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
||||
bufferSize = 50000 # Buffer size in bytes
|
||||
bufferSize = 10000 # Buffer size in bytes
|
||||
timeout = 15 # How long to wait for a connection to respond before timing out?
|
||||
maxClients = 20 # How many clients can be connected at maximum?
|
||||
maxClientsPerIP = 3 # How many clients can be connected at maximum, per IP?
|
||||
|
Loading…
Reference in New Issue
Block a user