Opened 3 years ago

Last modified 9 months ago

#32969 new Cleanup/optimization

Improve pickling of HttpResponse instances

Reported by: zatro Owned by: Anvesh Mishra
Component: HTTP handling Version: dev
Severity: Normal Keywords:
Cc: Keryn Knight, Anvesh Mishra, Ülgen Sarıkavak Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When pickling a HTTPResponse, rather than pickling all of its attributes just store what is needed for the creation of a new HttpResponse with the correct content, status code and headers.

See related discussion on ticket #23895 and its PR.

Change History (16)

comment:1 by Mariusz Felisiak, 3 years ago

Component: Core (Serialization)HTTP handling
Triage Stage: UnreviewedAccepted

Thanks, it's worth adding that pickling HttpResponse with CBV crashes:

>>> import pickle
>>> response = self.client.get('/cbv_view/')
>>> pickle.dumps(response)
...
AttributeError: Can't pickle ....

comment:2 by tigicion, 3 years ago

Owner: changed from nobody to tigicion
Status: newassigned

comment:4 by Mariusz Felisiak, 3 years ago

Patch needs improvement: set

I agree with Keryn's comment.

comment:5 by tigicion, 3 years ago

Patch needs improvement: unset

comment:6 by Keryn Knight, 3 years ago

Cc: Keryn Knight added
Patch needs improvement: set

Tentatively setting the flag back; I've left feedback and proposed a first sketch of how adapting SimpleTemplateResponse and TemplateResponse might go.

comment:7 by Mariusz Felisiak, 3 years ago

Needs tests: set

comment:8 by Anvesh Mishra, 3 years ago

Cc: Anvesh Mishra added
Owner: changed from tigicion to Anvesh Mishra

comment:9 by Anvesh Mishra, 3 years ago

Submitted the PR with all the suggested changes according to Keryn and Felix's comments on PR-14728

comment:10 by Mariusz Felisiak, 2 years ago

Needs tests: unset
Patch needs improvement: unset
Triage Stage: AcceptedReady for checkin

comment:11 by Mariusz Felisiak <felisiak.mariusz@…>, 2 years ago

Resolution: fixed
Status: assignedclosed

In d7f5bfd:

Fixed #32969 -- Fixed pickling HttpResponse and subclasses.

comment:12 by Mariusz Felisiak, 2 years ago

Type: BugCleanup/optimization

comment:13 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

In 173034b0:

Refs #34482 -- Reverted "Fixed #32969 -- Fixed pickling HttpResponse and subclasses."

This reverts commit d7f5bfd241666c0a76e90208da1e9ef81aec44db.

Thanks Márton Salomváry for the report.

comment:14 by Mariusz Felisiak <felisiak.mariusz@…>, 21 months ago

In 791407f:

[4.2.x] Refs #34482 -- Reverted "Fixed #32969 -- Fixed pickling HttpResponse and subclasses."

This reverts commit d7f5bfd241666c0a76e90208da1e9ef81aec44db.

Thanks Márton Salomváry for the report.

Backport of 173034b00589c083793d495e8b07e35be2cb1cf0 from main

comment:15 by Mariusz Felisiak, 21 months ago

Has patch: unset
Resolution: fixed
Status: closednew
Triage Stage: Ready for checkinAccepted

comment:16 by Ülgen Sarıkavak, 9 months ago

Cc: Ülgen Sarıkavak added
Note: See TracTickets for help on using tickets.
Back to Top