class Agent(object): def __init__(self, name, mta): self.agent_id = AgentID().generate() self.is_active = False self.name = name self.setupMTA(mta) def setupMTA(self, mta, logger=None): if mta: if logger: self.logger = logger else: self.logger = mta.logger self.mta = weakref_ref(mta) self.mailbox = Mailbox(self, mta) else: self.logger = None self.mta = None self.mailbox = None def __cmp__(self, other): return cmp(self.agent_id, other.agent_id) def __del__(self): try: self.debug("Destroy") self.deactivate() if self.mailbox: self.mailbox.unregister() self.destroy() except KeyboardInterrupt: self.error("Agent destruction interrupted!") self.send('application_interrupt') except FUSIL_ERRORS, error: writeError(self, error, "Agent destruction error")
def setupMTA(self, mta, logger=None): if mta: if logger: self.logger = logger else: self.logger = mta.logger self.mta = weakref_ref(mta) self.mailbox = Mailbox(self, mta) else: self.logger = None self.mta = None self.mailbox = None
def setupMTA(self, mta, logger=None): """ Create the mailbox and store a weak reference the message transfert agent (MTA). """ if mta: if logger: self.logger = logger else: self.logger = mta.logger self.mta = weakref_ref(mta) self.mailbox = Mailbox(self, mta) else: self.logger = None self.mta = None self.mailbox = None
class Agent(object): def __init__(self, name, mta): self.agent_id = AgentID().generate() self.is_active = False self.name = name self.setupMTA(mta) def setupMTA(self, mta, logger=None): """ Create the mailbox and store a weak reference the message transfert agent (MTA). """ if mta: if logger: self.logger = logger else: self.logger = mta.logger self.mta = weakref_ref(mta) self.mailbox = Mailbox(self, mta) else: self.logger = None self.mta = None self.mailbox = None def __cmp__(self, other): return cmp(self.agent_id, other.agent_id) def __del__(self): try: if hasattr(self, 'is_active'): self.deactivate() if hasattr(self, "mailbox") and self.mailbox: self.mailbox.unregister() self.destroy() except KeyboardInterrupt: self.error("Agent destruction interrupted!") self.send('application_interrupt') except PTRACE_ERRORS, error: writeError(self, error, "Agent destruction error") except: