#NEWLINE# def makeRunner( self ) : #NEWLINE# #INDENT# 'generator factory function to create generator to run this monitor\n        ' #NEWLINE# console . profuse ( '     Making Server Task Runner {0}\n' . format ( self . name ) ) #NEWLINE# self . status = STOPPED #NEWLINE# self . desire = STOP #NEWLINE# self . done = True #NEWLINE# try : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# control = ( yield self . status ) #NEWLINE# console . profuse ( '\n     Iterate Server {0} with control = {1} status = {2}\n' . format ( self . name , ControlNames . get ( control , 'Unknown' ) , StatusNames . get ( self . status , 'Unknown' ) ) ) #NEWLINE# if ( control == RUN ) : #NEWLINE# #INDENT# if ( ( self . status == STARTED ) or ( self . status == RUNNING ) ) : #NEWLINE# #INDENT# console . profuse ( '     Running Server {0} ...\n' . format ( self . name ) ) #NEWLINE# ( input , sa ) = self . server . receive ( ) #NEWLINE# if sa : #NEWLINE# #INDENT# ( shost , sport ) = sa #NEWLINE# #UNINDENT# output = b'' #NEWLINE# result = self . server . send ( output , self . dha ) #NEWLINE# self . status = RUNNING #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# console . profuse ( '     Need to Start Server {0}\n' . format ( self . name ) ) #NEWLINE# self . desire = START #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( control == READY ) : #NEWLINE# #INDENT# console . profuse ( '     Readying Server {0} ...\n' . format ( self . name ) ) #NEWLINE# self . status = READIED #NEWLINE# self . desire = START #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( control == START ) : #NEWLINE# #INDENT# console . terse ( '     Starting Server {0} ...\n' . format ( self . name ) ) #NEWLINE# if self . reopen ( ) : #NEWLINE# #INDENT# self . desire = RUN #NEWLINE# self . status = STARTED #NEWLINE# self . done = False #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . desire = STOP #NEWLINE# self . status = STOPPED #NEWLINE# self . done = True #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( control == STOP ) : #NEWLINE# #INDENT# if ( ( self . status == RUNNING ) or ( self . status == STARTED ) ) : #NEWLINE# #INDENT# console . terse ( '     Stopping Server {0} ...\n' . format ( self . name ) ) #NEWLINE# self . close ( ) #NEWLINE# self . desire = STOP #NEWLINE# self . status = STOPPED #NEWLINE# self . done = True #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# console . terse ( '     Server {0} not started or running.\n' . format ( self . name ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( control == ABORT ) : #NEWLINE# #INDENT# console . profuse ( '     Aborting Server {0} ...\n' . format ( self . name ) ) #NEWLINE# self . close ( ) #NEWLINE# self . desire = ABORT #NEWLINE# self . status = ABORTED #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . desire = ABORT #NEWLINE# self . status = ABORTED #NEWLINE# console . profuse ( '     Aborting Server {0}, bad control = {1}\n' . format ( self . name , CommandNames [ control ] ) ) #NEWLINE# self . close ( ) #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# self . stamp = self . store . stamp #NEWLINE# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# console . profuse ( '     Exception causing Abort Server {0} ...\n' . format ( self . name ) ) #NEWLINE# self . desire = ABORT #NEWLINE# self . status = ABORTED #NEWLINE# self . close ( )