#NEWLINE# def _handleOneMessage( self , envelope ) : #NEWLINE# #INDENT# msg = envelope . message #NEWLINE# import logging #NEWLINE# thesplog ( 'ACTOR got %s' , envelope . identify ( ) , level = logging . DEBUG ) #NEWLINE# ( handled , result ) = self . _handleReplicatorMessages ( envelope ) #NEWLINE# if handled : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# if isinstance ( msg , PendingActorResponse ) : #NEWLINE# #INDENT# return self . _pendingActorResponse ( envelope ) #NEWLINE# #UNINDENT# if isinstance ( msg , Thespian_StatusReq ) : #NEWLINE# #INDENT# return self . getActorStatus ( envelope ) #NEWLINE# #UNINDENT# if isinstance ( msg , NewCapabilities ) : #NEWLINE# #INDENT# return self . checkNewCapabilities ( envelope ) #NEWLINE# #UNINDENT# if isinstance ( msg , SetLogging ) : #NEWLINE# #INDENT# return self . setLoggingControls ( envelope ) #NEWLINE# #UNINDENT# actor_result = None #NEWLINE# if ( ( not getattr ( self , '_exiting' , False ) ) or isinstance ( msg , ( ActorExitRequest , ChildActorExited ) ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . _sCBStats . inc ( 'Actor.Message Received.To Actor' ) #NEWLINE# actor_result = self . actorInst . receiveMessage ( msg , envelope . sender ) #NEWLINE# #UNINDENT# except Exception as ex : #NEWLINE# #INDENT# thesplog ( 'Handling exception on msg "%s": %s' , msg , ex , exc_info = True ) #NEWLINE# self . _sCBStats . inc ( 'Actor.Message Received.Caused Primary Exception' ) #NEWLINE# if ( not isinstance ( msg , ActorExitRequest ) ) : #NEWLINE# #INDENT# import traceback #NEWLINE# thesplog ( 'Actor %s @ %s retryable exception on message %s: %s' , self . _actorClass , self . transport . myAddress , msg , traceback . format_exc ( ) , level = logging . WARNING ) #NEWLINE# logging . getLogger ( str ( self . _actorClass ) ) . warning ( 'Actor %s @ %s retryable exception on message %s' , self . _actorClass , self . transport . myAddress , msg , exc_info = True ) #NEWLINE# try : #NEWLINE# #INDENT# actor_result = self . actorInst . receiveMessage ( copy . deepcopy ( msg ) , envelope . sender ) #NEWLINE# #UNINDENT# except Exception : #NEWLINE# #INDENT# self . _sCBStats . inc ( 'Actor.Message Received.Caused Secondary Exception' ) #NEWLINE# thesplog ( 'Actor %s @ %s second exception on message %s: %s' , self . _actorClass , self . transport . myAddress , msg , traceback . format_exc ( ) , level = logging . ERROR ) #NEWLINE# logging . getLogger ( str ( self . _actorClass ) ) . error ( 'Actor %s @ %s second exception on message %s' , self . _actorClass , self . transport . myAddress , msg , exc_info = True ) #NEWLINE# if ( not isinstance ( msg , PoisonMessage ) ) : #NEWLINE# #INDENT# self . _send_intent ( TransmitIntent ( envelope . sender , PoisonMessage ( msg ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if isinstance ( msg , ActorExitRequest ) : #NEWLINE# #INDENT# if ( getattr ( self , '_exiting' , None ) is not None ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# return self . _actorExit ( msg ) #NEWLINE# #UNINDENT# if hasattr ( self . transport , 'set_watch' ) : #NEWLINE# #INDENT# self . transport . set_watch ( ( actor_result . filenos if isinstance ( actor_result , ThespianWatch ) else [ ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( actor_result , ThespianWatch ) : #NEWLINE# #INDENT# logging . getLogger ( str ( self . _actorClass ) ) . error ( 'Actor %s @ %s does not support ThespianWatch' , self . _actorClass , self . transport . myAddress ) #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( msg , ChildActorExited ) : #NEWLINE# #INDENT# return self . _handleChildExited ( msg . childAddress ) #NEWLINE# #UNINDENT# return True