Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer response headers processing to a finished callback #310

Merged
merged 4 commits into from
May 30, 2017

Conversation

a3kov
Copy link

@a3kov a3kov commented May 27, 2017

Fixes #309

Copy link
Member

@mmerickel mmerickel left a comment

Choose a reason for hiding this comment

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

I think you can just register the finished callback in the __init__ and avoid keeping a reference to the request object.

As far as chaining response callbacks that's fine with me I suppose.

@a3kov
Copy link
Author

a3kov commented May 30, 2017

I still need a reference to an actual response object. Inside __init__ there's no response yet (too early) and in the finished callback no response either (too late). So is there a difference if I remove reference to the request, but then I need to provide a reference to the response ? :P

@a3kov
Copy link
Author

a3kov commented May 30, 2017

The only worry with this approach is, if it's possible that __init__ will run, but process_response() will not, then there's no reference to response and we get an error. I'm not sure if we need to account for that (if the described case is possible in theory) by using getattr or something. The initial approach by referencing the request was better in this sense

@mmerickel
Copy link
Member

mmerickel commented May 30, 2017

There is really no point in trying to be the last finished callback as even the first one does not have access to the response and if anyone is figuring out how to access it to change it there then I do not care if the toolbar tracks those changes or not. Adding the jump logic here is too defensive for this particular feature.

Option 1: Just tweak the panel to add a NewResponse subscriber via config.inject_parent_action. It will be guaranteed to be the last subscriber added in most cases and that thing executes after response callbacks.

Option 2: Use a single finished callback and hang onto the response from process_response like you're doing now and pull the headers when it is invoked.

@mmerickel
Copy link
Member

LGTM, thanks! We could initialize the self.data earlier but I can't envision a scenario in which the current code breaks so I'm not too worried about it. Right now we call process_response even if the response is the debugger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants