def process_async_task(headers, request_body): """Process an Async task and execute the requested function.""" async_options = json.loads(request_body) async = async_from_options(async_options) _log_task_info(headers) logging.info(async._function_path) with context.execution_context_from_async(async): run_job() return 200, async._function_path
def test_check_recursion_level_execution_context(self): """Ensure that when there is an existing Async that the correct values are pulled and incremented from there, not the defaults. """ from furious.async import Async from furious.context import execution_context_from_async context_async = Async("something", _recursion={"current": 42, "max": 77}) new_async = Async("something_else") with execution_context_from_async(context_async): new_async._increment_recursion_level() self.assertEqual(43, new_async.recursion_depth) options = new_async.get_options()["_recursion"] self.assertEqual(77, options["max"])
def test_check_recursion_level_overridden_interior_max(self): """Ensure that when there is an existing Async that the correct values are pulled and incremented from there, unless the interior Async sets it's own custom max. """ from furious.async import Async from furious.context import execution_context_from_async context_async = Async("something", _recursion={"current": 42, "max": 77}) new_async = Async("something_else", _recursion={"max": 89}) with execution_context_from_async(context_async): new_async._increment_recursion_level() options = new_async.get_options()["_recursion"] self.assertEqual(43, options["current"]) self.assertEqual(89, options["max"])
def test_check_recursion_level_execution_context(self): """Ensure that when there is an existing Async that the correct values are pulled and incremented from there, not the defaults. """ from furious. async import Async from furious.context import execution_context_from_async context_async = Async("something", _recursion={ 'current': 42, 'max': 77 }) new_async = Async("something_else") with execution_context_from_async(context_async): new_async._increment_recursion_level() self.assertEqual(43, new_async.recursion_depth) options = new_async.get_options()['_recursion'] self.assertEqual(77, options['max'])
def test_check_recursion_level_overridden_interior_max(self): """Ensure that when there is an existing Async that the correct values are pulled and incremented from there, unless the interior Async sets it's own custom max. """ from furious. async import Async from furious.context import execution_context_from_async context_async = Async("something", _recursion={ 'current': 42, 'max': 77 }) new_async = Async("something_else", _recursion={'max': 89}) with execution_context_from_async(context_async): new_async._increment_recursion_level() options = new_async.get_options()['_recursion'] self.assertEqual(43, options['current']) self.assertEqual(89, options['max'])