stop heartbeating when agent is stopped
This commit is contained in:
parent
547d22d598
commit
0134631ab3
@ -142,6 +142,7 @@ class TeethAgentHeartbeater(threading.Thread):
|
|||||||
backoff_factor = 2.7
|
backoff_factor = 2.7
|
||||||
|
|
||||||
def __init__(self, agent):
|
def __init__(self, agent):
|
||||||
|
super(TeethAgentHeartbeater, self).__init__()
|
||||||
self.agent = agent
|
self.agent = agent
|
||||||
self.api = overlord_agent_api.APIClient(agent.api_url)
|
self.api = overlord_agent_api.APIClient(agent.api_url)
|
||||||
self.stop_event = threading.Event()
|
self.stop_event = threading.Event()
|
||||||
@ -172,6 +173,10 @@ class TeethAgentHeartbeater(threading.Thread):
|
|||||||
|
|
||||||
return deadline
|
return deadline
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
self.stop_event.set()
|
||||||
|
return self.join()
|
||||||
|
|
||||||
|
|
||||||
class BaseTeethAgent(object):
|
class BaseTeethAgent(object):
|
||||||
def __init__(self, listen_host, listen_port, api_url, mode):
|
def __init__(self, listen_host, listen_port, api_url, mode):
|
||||||
@ -233,3 +238,4 @@ class BaseTeethAgent(object):
|
|||||||
self.started_at = time.time()
|
self.started_at = time.time()
|
||||||
self.heartbeater.start()
|
self.heartbeater.start()
|
||||||
serving.run_simple(self.listen_host, self.listen_port, self.api)
|
serving.run_simple(self.listen_host, self.listen_port, self.api)
|
||||||
|
self.heartbeater.stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user