Maintenance will be performed on,,, and starting 2 March 2020 at approximately 8am MST. It is expected to take around 10 minutes and will include a short period of downtime towards the end of the maintenance window. Please direct any comments, concerns, or questions to

Commit dd107fa3 authored by Leo Pound Singer's avatar Leo Pound Singer

Make HTTPError pickleable

According to the [Celery manual]:

> A rarely known Python fact is that exceptions must conform to
> some simple rules to support being serialized by the pickle
> module.
> Tasks that raise exceptions that aren’t pickleable won’t work
> properly when Pickle is used as the serializer.
> To make sure that your exceptions are pickleable the exception
> MUST provide the original arguments it was instantiated with in
> its .args attribute. The simplest way to ensure this is to have
> the exception call Exception.__init__.

The class `ligo.gracedb.exceptions.HTTPError` does not follow
these rules, so it is not pickleable. Here is a demonstration of

    >>> import pickle
    >>> from ligo.gracedb.exceptions import HTTPError
    >>> pickle.loads(pickle.dumps(HTTPError(404, 'foo', 'bar')))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: __init__() missing 2 required positional arguments:
    'reason' and 'message'

This patch makes `HTTPError` pickleable so that it can be properly
represented in Celery task stack traces.

[Celery manual]:
parent ab32741c
Pipeline #26817 passed with stages
in 3 minutes and 52 seconds
......@@ -6,4 +6,4 @@ class HTTPError(Exception):
self.status = status
self.reason = reason
self.message = message
Exception.__init__(self, (status, '{} / {}'.format(reason, message)))
Exception.__init__(self, status, reason, message)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment