GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: add reduce to allow errors to be pickled by bcvandendool · Pull Request #148 · sendgrid/python-http-client

Conversation

@bcvandendool

@bcvandendool bcvandendool commented Jan 12, 2021

Copy link
Copy Markdown
Contributor

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

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Jan 12, 2021
@codecov

codecov Bot commented Jan 12, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

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%) ⬆️
tests/test_unit.py 99.33% <100.00%> (+0.07%) ⬆️

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bcvandendool
fix: add reduce to allow errors to be pickled
5668df9
@bcvandendool
bcvandendool force-pushed the fix-error-pickling branch 3 times, most recently from 57eed5e to f44abad Compare January 12, 2021 20:09
@bcvandendool
fix: pickling test case handle python 2
c75074c
python 2 adds a __cause__ that is None to the __dict__ of the thrown error, failing the assertion
@bcvandendool
bcvandendool force-pushed the fix-error-pickling branch from f44abad to c75074c Compare January 12, 2021 20:11
@JenniferMah JenniferMah changed the title <fix>: add reduce to allow errors to be pickled fix: add reduce to allow errors to be pickled Jan 13, 2021
JenniferMah
JenniferMah reviewed Jan 13, 2021
View reviewed changes

@JenniferMah JenniferMah left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR @bcvandendool!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread tests/test_unit.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

thinkingserious
thinkingserious approved these changes Feb 10, 2021
View reviewed changes
@thinkingserious
thinkingserious merged commit dafd024 into sendgrid:main Feb 10, 2021
@Shubham-Padkonde Shubham-Padkonde mentioned this pull request Oct 4, 2026
fix: preserve HTTP error subclasses when pickling #163
Open
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@thinkingserious thinkingserious thinkingserious approved these changes
+1 more reviewer
@JenniferMah JenniferMah JenniferMah left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

status: code review request requesting a community code review or review from Twilio

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

pickle / celery breaks with exceptions

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bcvandendool @thinkingserious @JenniferMah
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.