Add sleep if no data is available to read, to prevent ridiculous CPU usage

develop
Sven Slootweg 13 years ago
parent 7cce3da297
commit 185af55f84

@ -23,6 +23,7 @@ client_map[client.ssl_sock.fileno()] = client.client
while True:
readable, writable, error = select.select(select_inputs, select_outputs, select_inputs)
if len(readable) > 0:
for sock in readable:
try:
data = sock.recv(1024)
@ -40,4 +41,6 @@ while True:
select.select([], [sock], [])
else:
raise
else:
time.sleep(0.010)

@ -177,6 +177,7 @@ class SSLDaemon:
while self.select_inputs:
readable, writable, error = select.select(self.select_inputs, self.select_outputs, self.select_inputs)
if len(readable) > 0:
for sock in readable:
try:
if sock is bindsocket:
@ -209,3 +210,5 @@ class SSLDaemon:
select.select([], [sock], [])
else:
raise
else:
time.sleep(0.010)

Loading…
Cancel
Save