def maybe_shutdown():
 if ((should_stop is not None) and (should_stop is not False)):
  raise WorkerShutdown(should_stop)
 elif ((should_terminate is not None) and (should_terminate is not False)):
  raise WorkerTerminate(should_terminate)

def maybe_shutdown ( ) : if ( ( should_stop is not None ) and ( should_stop is not False ) ) : raise WorkerShutdown ( should_stop ) elif ( ( should_terminate is not None ) and ( should_terminate is not False ) ) : raise WorkerTerminate ( should_terminate )
shutdown if flags have been set .