Exemple #1
0
 def main(self):
     pat, msg = self.receive(actor.CALL_PATTERN)
     try:
         raise ValueError("testexc")
     except ValueError, e:
         formatted = exc.format_exc()
         self.respond_exception(msg, formatted)
Exemple #2
0
 def main(self):
     pat,msg = self.receive(actor.CALL_PATTERN)
     try:
         raise ValueError("testexc")
     except ValueError,e:
         formatted = exc.format_exc()
         self.respond_exception(msg, formatted)
Exemple #3
0
    def run(self):
        """Do not override.

        Run the Actor's main method in this greenlet. Send the function's
        result to the Actor's exit event. Also, catch exceptions and send
        messages with the exception details to any linked Actors, and send
        an exit message to any linked Actors after main has completed.
        """
        args, kw = self._args
        del self._args
        to_run = self._to_run
        del self._to_run
        try:
            result = to_run(*args, **kw)
            self._exit_event.send(result)
        except:
            if NOISY_ACTORS:
                print "Actor had an exception:"
                traceback.print_exc()
            result = None
            formatted = exc.format_exc()
            for link in self._links:
                link.cast({'address': self.address, 'exception': formatted})
            exc_info = sys.exc_info()
            self._exit_event.send_exception(*exc_info)
        for link in self._exit_links:
            link.cast({'address': self.address, 'exit': result})
        self.all_actors.pop(self.actor_id)
Exemple #4
0
    def _run(self):
        """Do not override.

        Run the Actor's main method in this greenlet. Send the function's
        result to the Actor's exit event. Also, catch exceptions and send
        messages with the exception details to any linked Actors, and send
        an exit message to any linked Actors after main has completed.
        """
        args, kw = self._args
        del self._args
        to_run = self._to_run
        del self._to_run
        try:
            result = to_run(*args, **kw)
            self._exit_event.set(result)
        except:
            exctype, excvalue, excinfo = sys.exc_info()
            if NOISY_ACTORS:
                print "Actor had an exception:"
                traceback.print_exc()
            result = None
            formatted = exc.format_exc()
            for link in self._alinks:
                link.cast({'address': self.address, 'exception': formatted})
            self._exit_event.set_exception(excvalue)
        for link in self._exit_links:
            link.cast({'address': self.address, 'exit': result})
        self.all_actors.pop(self.actor_id)
Exemple #5
0
 def main(self, *args, **kw):
     """Implement the actor main loop by waiting forever for messages.
     
     Do not override.
     """
     self.start(*args, **kw)
     try:
         while True:
             pattern, message = self.receive(CALL_PATTERN)
             method = getattr(self, message['method'], None)
             if method is None:
                 self.respond_invalid_method(message, message['method'])
                 continue
             try:
                 self.respond(message,  method(message['message']))
             except Exception, e:
                 formatted = exc.format_exc()
                 self.respond_exception(message, formatted)
     finally:
         self.stop(*args, **kw)
Exemple #6
0
 def main(self, *args, **kw):
     """Implement the actor main loop by waiting forever for messages.
     
     Do not override.
     """
     self.server_start(*args, **kw)
     try:
         while True:
             pattern, message = self.receive(CALL_PATTERN)
             method = getattr(self, message['method'], None)
             if method is None:
                 self.respond_invalid_method(message, message['method'])
                 continue
             try:
                 self.respond(message, method(message['message']))
             except Exception, e:
                 formatted = exc.format_exc()
                 self.respond_exception(message, formatted)
     finally:
         self.server_stop(*args, **kw)