sendgrid / python-http-client

Twilio SendGrid's Python HTTP Client for calling APIs
https://sendgrid.com
MIT License
125 stars 101 forks source link

fix: add reduce to allow errors to be pickled #148

Closed bcvandendool closed 3 years ago

bcvandendool commented 3 years ago

Fixes

Fixes #139 When an error occurs when running the library in a celery shared task, celery tries to pickle the error which fails. This is because the init function requires a parameter that it cannot automatically reconstruct from the info stored in the class. This modifies the init function to allow both the original way of initializing, as well as being able to specify all the arguments separately. The reduce function has been implemented to explicitly tell it how it should pickle this class, and which parameters to use. A test has been added to show that the errors can now be pickled.

Checklist

If you have questions, please file a support ticket, or create a GitHub Issue in this repository.

codecov[bot] commented 3 years ago

Codecov Report

Merging #148 (c75074c) into main (6d62911) will increase coverage by 0.32%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
+ Coverage   95.14%   95.46%   +0.32%     
==========================================
  Files           6        6              
  Lines         309      331      +22     
==========================================
+ Hits          294      316      +22     
  Misses         15       15              
Impacted Files Coverage Δ
python_http_client/exceptions.py 97.82% <100.00%> (+0.39%) :arrow_up:
tests/test_unit.py 99.33% <100.00%> (+0.07%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6d62911...c75074c. Read the comment docs.