Esempio n. 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']
Esempio n. 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']
Esempio n. 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']
Esempio n. 4
0
    def _handle_task(self):
        """Pass request info to the async framework."""
        headers = self.request.headers

        message = None
        try:
            status_code, output = process_async_task(
                headers, self.request.body)
        except AbortAndRestart as restart:
            # Async retry status code
            status_code = 549
            message = 'Retry Async Task'
            output = str(restart)

        self.response.set_status(status_code, message)
        self.response.out.write(output)
Esempio n. 5
0
    def _handle_task(self):
        """Pass request info to the async framework."""
        headers = self.request.headers

        message = None
        try:
            status_code, output = process_async_task(headers,
                                                     self.request.body)
        except AbortAndRestart as restart:
            # Async retry status code
            status_code = 549
            message = 'Retry Async Task'
            output = str(restart)

        self.response.set_status(status_code, message)
        self.response.out.write(output)