commit 5bbf0408ce9233ada7f3de0bcd04a2892b351964 parent 976b00ca85424d87bd2f3222970aa811da50ef8e Author: Sheng <webmaster0115@gmail.com> Date: Thu, 4 Jul 2019 19:36:23 +0800 Updated clear_worker Diffstat:
M | webssh/worker.py | | | 17 | +++++++---------- |
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/webssh/worker.py b/webssh/worker.py @@ -13,16 +13,13 @@ clients = {} # {ip: {id: worker}} def clear_worker(worker, clients): ip = worker.src_addr[0] workers = clients.get(ip) - if workers: - try: - workers.pop(worker.id) - except KeyError: - pass - else: - if not workers: - clients.pop(ip) - if not clients: - clients.clear() + assert worker.id in workers + workers.pop(worker.id) + + if not workers: + clients.pop(ip) + if not clients: + clients.clear() def recycle_worker(worker):