Skip to content

agent.py

Agent

shutdown(self)

Shutdown procedure, call super().shutdown() if overriding

Source code in agents/agent.py
def shutdown(self):
    """
    Shutdown procedure, call super().shutdown() if overriding
    """
    self.log.info("set exit event ...")
    self.exit_event.set()

    self.log.info("wait for initialization before cleaning up ...")
    self.initialized_event.wait()

    # join threads
    self.log.info("joining threads ...")
    for t in self.threads:
        self.log.info(f"joining {t}")
        t.join()

    # destroy zmq sockets
    for k, v in self.zmq_sockets.items():
        self.log.info(f"closing socket {k} ...")
        v["socket"].close()
    self.zmq_context.term()