Exemple #1
0
def _execute_task(task, non_furious_url_prefixes=None,
                  non_furious_handler=None):
    """Extract the body and header from the task and process it.

    :param task: :class: `taskqueue.Task`
    :param non_furious_url_prefixes: :class: `list` of url prefixes that the
                                 furious task runner will run.
    :param non_furious_handler: :class: `func` handler for non furious tasks to
                                run within.
    """
    if not _is_furious_task(task, non_furious_url_prefixes,
                            non_furious_handler):
        return

    # Ensure each test looks like it is in a new request.
    os.environ['REQUEST_ID_HASH'] = uuid.uuid4().hex

    # Decode the body and process the task.
    body = base64.b64decode(task['body'])

    return_code, func_path = process_async_task(dict(task['headers']), body)

    # TODO: Possibly do more with return_codes.

    # Cleanup context since we will be executing more tasks in this process.
    _clear_context()

    del os.environ['REQUEST_ID_HASH']
Exemple #2
0
def _execute_task(task,
                  non_furious_url_prefixes=None,
                  non_furious_handler=None):
    """Extract the body and header from the task and process it.

    :param task: :class: `taskqueue.Task`
    :param non_furious_url_prefixes: :class: `list` of url prefixes that the
                                 furious task runner will run.
    :param non_furious_handler: :class: `func` handler for non furious tasks to
                                run within.
    """
    if not _is_furious_task(task, non_furious_url_prefixes,
                            non_furious_handler):
        return

    # Ensure each test looks like it is in a new request.
    os.environ['REQUEST_ID_HASH'] = uuid.uuid4().hex

    # Decode the body and process the task.
    body = base64.b64decode(task['body'])

    return_code, func_path = process_async_task(dict(task['headers']), body)

    # TODO: Possibly do more with return_codes.

    # Cleanup context since we will be executing more tasks in this process.
    _clear_context()

    del os.environ['REQUEST_ID_HASH']
Exemple #3
0
def _execute_task(task):
    """Extract the body and header from the task and process it."""

    # Ensure each test looks like it is in a new request.
    os.environ['REQUEST_ID_HASH'] = uuid.uuid4().hex

    # Decode the body and process the task.
    body = base64.b64decode(task['body'])
    return_code, func_path = process_async_task(dict(task['headers']), body)

    # TODO: Possibly do more with return_codes.

    # Cleanup context since we will be executing more tasks in this process.
    _clear_context()
    del os.environ['REQUEST_ID_HASH']
Exemple #4
0
    def test_clear_context(self):
        """Ensure clear_context successfully clears attributes set during
        initialization from the local context.
        """

        from furious.context import _local
        from furious.context._local import _clear_context
        from furious.context._local import get_local_context

        # Initialize the local context by retrieving it.
        get_local_context()

        # Make sure there is something on the local context we need to clear.
        self.assertTrue(hasattr(_local._local_context, "registry"))

        _clear_context()

        # Make sure local context entries have been cleared
        self.assertFalse(hasattr(_local._local_context, "_executing_async"))
        self.assertFalse(hasattr(_local._local_context, "_executing_async_context"))
        self.assertFalse(hasattr(_local._local_context, "_initialized"))
        self.assertFalse(hasattr(_local._local_context, "registry"))
    def test_clear_context(self):
        """Ensure clear_context successfully clears attributes set during
        initialization from the local context.
        """

        from furious.context import _local
        from furious.context._local import _clear_context
        from furious.context._local import get_local_context

        # Initialize the local context by retrieving it.
        get_local_context()

        # Make sure there is something on the local context we need to clear.
        self.assertTrue(hasattr(_local._local_context, 'registry'))

        _clear_context()

        # Make sure local context entries have been cleared
        self.assertFalse(hasattr(_local._local_context, '_executing_async'))
        self.assertFalse(
            hasattr(_local._local_context, '_executing_async_context'))
        self.assertFalse(hasattr(_local._local_context, '_initialized'))
        self.assertFalse(hasattr(_local._local_context, 'registry'))