Updated clear_worker

pull/75/head
Sheng 2019-07-04 19:36:23 +08:00
parent 976b00ca85
commit 5bbf0408ce
1 changed files with 7 additions and 10 deletions

View File

@ -13,16 +13,13 @@ clients = {} # {ip: {id: worker}}
def clear_worker(worker, clients): def clear_worker(worker, clients):
ip = worker.src_addr[0] ip = worker.src_addr[0]
workers = clients.get(ip) workers = clients.get(ip)
if workers: assert worker.id in workers
try: workers.pop(worker.id)
workers.pop(worker.id)
except KeyError: if not workers:
pass clients.pop(ip)
else: if not clients:
if not workers: clients.clear()
clients.pop(ip)
if not clients:
clients.clear()
def recycle_worker(worker): def recycle_worker(worker):