Exemple #1
0
def _create_supervisor(event, context=None):
    """Returns a new supervisor based on the
    environment.
    Binary mode by default"""
    supervisor = None
    if SysUtils.is_lambda_environment():
        supervisor = LambdaSupervisor(event, context)
    else:
        supervisor = BinarySupervisor()
    return supervisor
Exemple #2
0
 def run(self):
     """Generic method to launch the supervisor execution."""
     try:
         if is_batch_execution() and SysUtils.is_lambda_environment():
             # Only delegate to batch
             self.supervisor.execute_function()
         else:
             self._parse_input()
             self.supervisor.execute_function()
             self._parse_output()
         get_logger().info('Creating response')
         return self.supervisor.create_response()
     except FaasSupervisorError as fse:
         get_logger().exception(fse)
         get_logger().error('Creating error response')
         return self.supervisor.create_error_response()