From 2e087cf5214f93685e6ec1e8b5ecff9ff6b9acda Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Thu, 7 Apr 2022 19:14:24 +0530 Subject: [PATCH] Agent: Add try/except block in _calculate_timeout in MonkeyTunnel --- monkey/infection_monkey/tunnel.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/monkey/infection_monkey/tunnel.py b/monkey/infection_monkey/tunnel.py index 64b204b15..26368bff6 100644 --- a/monkey/infection_monkey/tunnel.py +++ b/monkey/infection_monkey/tunnel.py @@ -200,8 +200,11 @@ class MonkeyTunnel(Thread): proxy.stop() proxy.join() - def _calculate_timeout(self): - return QUIT_TIMEOUT - (time.time() - get_last_serve_time()) + def _calculate_timeout(self) -> float: + try: + return QUIT_TIMEOUT - (time.time() - get_last_serve_time()) + except TypeError: # get_last_serve_time() may return None + return 0.0 def get_tunnel_for_ip(self, ip: str):