Esempio n. 1
0
File: base.py Progetto: enquos/kombu
        self.on_header = maybe_promise(on_header)
        if kwargs:
            for k, v in items(kwargs):
                setattr(self, k, v)
        if not isinstance(headers, Headers):
            headers = Headers(headers or {})
        self.headers = headers

    def then(self, callback, errback=None):
        self.on_ready.then(callback, errback)

    def __repr__(self):
        return "<Request: {0.method} {0.url} {0.body}>".format(self)


Thenable.register(Request)


class Response(object):
    """HTTP Response.

    :param request: See :attr:`request`.
    :keyword code: See :attr:`code`.
    :keyword headers: See :attr:`headers`.
    :keyword buffer: See :attr:`buffer`
    :keyword effective_url: See :attr:`effective_url`.
    :keyword status: See :attr:`status`.

    .. attribute:: request

        :class:`Request` object used to get this response.
Esempio n. 2
0
                The task executed successfully. The :attr:`result` attribute
                then contains the tasks return value.

        """
        return self._get_task_meta()['status']
    status = state  # XXX compat

    @property
    def task_id(self):
        """compat alias to :attr:`id`"""
        return self.id

    @task_id.setter  # noqa
    def task_id(self, id):
        self.id = id
Thenable.register(AsyncResult)


@python_2_unicode_compatible
class ResultSet(ResultBase):
    """Working with more than one result.

    :param results: List of result instances.

    """
    _app = None

    #: List of results in in the set.
    results = None

    def __init__(self, results, app=None, ready_barrier=None, **kwargs):
Esempio n. 3
0
        self.on_header = maybe_promise(on_header)
        if kwargs:
            for k, v in items(kwargs):
                setattr(self, k, v)
        if not isinstance(headers, Headers):
            headers = Headers(headers or {})
        self.headers = headers

    def then(self, callback, errback=None):
        self.on_ready.then(callback, errback)

    def __repr__(self):
        return '<Request: {0.method} {0.url} {0.body}>'.format(self)


Thenable.register(Request)


class Response(object):
    """HTTP Response.

    :param request: See :attr:`request`.
    :keyword code: See :attr:`code`.
    :keyword headers: See :attr:`headers`.
    :keyword buffer: See :attr:`buffer`
    :keyword effective_url: See :attr:`effective_url`.
    :keyword status: See :attr:`status`.

    .. attribute:: request

        :class:`Request` object used to get this response.