CLIENT-SERVER: improve tinysocket

bzr revid: ced-3d982a7e0d38ab5f02fe518fd26b0806b36be6ba
This commit is contained in:
ced 2007-01-30 08:15:20 +00:00
parent 57b9d4d22f
commit 009458b21f
2 changed files with 9 additions and 6 deletions

View File

@ -313,7 +313,7 @@ class TinySocketClientThread(threading.Thread):
tb = sys.exc_info()[2] tb = sys.exc_info()[2]
pdb.post_mortem(tb) pdb.post_mortem(tb)
ts.mysend(e, exception=True) ts.mysend(e, exception=True)
self.sock.shutdown(socket.SHUT_RDWR) self.sock.close()
self.threads.remove(self) self.threads.remove(self)
return True return True
except Exception, e: except Exception, e:
@ -322,7 +322,8 @@ class TinySocketClientThread(threading.Thread):
return False return False
def stop(self): def stop(self):
self.running = False self.running = False
self.sock.shutdown(socket.SHUT_RDWR) # self.sock.shutdown(socket.SHUT_RDWR)
# self.sock.close()
class TinySocketServerThread(threading.Thread): class TinySocketServerThread(threading.Thread):
def __init__(self, interface, port, secure=False): def __init__(self, interface, port, secure=False):
@ -347,16 +348,19 @@ class TinySocketServerThread(threading.Thread):
ct.start() ct.start()
self.threads.append(ct) self.threads.append(ct)
# print "threads size:", len(self.threads) # print "threads size:", len(self.threads)
self.socket.close()
except Exception, e: except Exception, e:
print "exception", e print "exception server", e
self.socket.close()
return False return False
def stop(self): def stop(self):
self.running=False self.running=False
for t in self.threads: for t in self.threads:
print "threads" print "thread"
t.join() t.stop()
self.socket.shutdown(socket.SHUT_RDWR) self.socket.shutdown(socket.SHUT_RDWR)
self.socket.close()
# vim:noexpandtab: # vim:noexpandtab:

View File

@ -233,7 +233,6 @@ logger.notifyChannel("web-services", netsvc.LOG_INFO, "starting TinySocket servi
def handler(signum, frame): def handler(signum, frame):
from tools import config from tools import config
tinySocket.stop() tinySocket.stop()
tinySocket.join()
httpd.stop() httpd.stop()
netsvc.Agent.quit() netsvc.Agent.quit()
if config['pidfile']: if config['pidfile']: