Exemple #1
0
    def status(self):
        """Return the async job status from server.

        Once a job result is retrieved via func:`arango.job.AsyncJob.result`
        method, it is deleted from server and subsequent status queries will
        fail.

        :return: Async job status. Possible values are "pending" (job is still
            in queue), "done" (job finished or raised an error), or "cancelled"
            (job was cancelled before completion).
        :rtype: str | unicode
        :raise arango.exceptions.AsyncJobStatusError: If retrieval fails.
        """
        request = Request(method='get',
                          endpoint='/_api/job/{}'.format(self._id))
        resp = self._conn.send_request(request)
        if resp.status_code == 204:
            return 'pending'
        elif resp.is_success:
            return 'done'
        elif resp.error_code == 404:
            error_message = 'job {} not found'.format(self._id)
            raise AsyncJobStatusError(resp, request, error_message)
        else:
            raise AsyncJobStatusError(resp, request)
Exemple #2
0
        def handler(res):
            if res.status_code == 204:
                self.update('pending')
            elif res.status_code in HTTP_OK:
                self.update('done')
            elif res.status_code == 404:
                raise AsyncJobStatusError(res,
                                          'Job {} missing'.format(self.id))
            else:
                raise AsyncJobStatusError(res)

            return self._status
Exemple #3
0
    def status(self):
        """Return the status of the async job from the server.

        :returns: the status of the async job, which can be ``"pending"`` (the
            job is still in the queue), ``"done"`` (the job finished or raised
            an exception)
        :rtype: str
        :raises arango.exceptions.AsyncJobStatusError: if the status of the
            async job cannot be retrieved from the server
        """
        res = self._conn.get('/_api/job/{}'.format(self.id))
        if res.status_code == 204:
            return 'pending'
        elif res.status_code in HTTP_OK:
            return 'done'
        elif res.status_code == 404:
            raise AsyncJobStatusError(res, 'Job {} missing'.format(self.id))
        else:
            raise AsyncJobStatusError(res)