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

Response does not close after use #65

Open
Zoupers opened this issue Apr 18, 2024 · 0 comments
Open

Response does not close after use #65

Zoupers opened this issue Apr 18, 2024 · 0 comments

Comments

@Zoupers
Copy link

Zoupers commented Apr 18, 2024

self.resp = resp
if self.req.is_response_stream_current:
if self.req.response_stream_file:
for buffer in self.req.response.iter_content(chunk_size=2048):
self.req.response_stream_file.write(buffer)
resp.data = self.req.response_stream_file
else:
resp.data = self.req.response.content
self.req.response.close()
return
resp_json = self.req.response.json()
self.config.logger.debug("request http_path:%s, response status code:%d, response body:%s" % (
self.req.http_path, self.req.response.status_code, resp_json))
if isinstance(resp_json, dict):
resp.code = resp_json.get('code')
resp.msg = resp_json.get('msg')
resp.error = make_datatype(ResponseError, resp_json.get('error'))
if self.req.no_data_field:
resp.data = make_datatype(self.req.output_class, resp_json)
else:

As above, there should have a corresponding close call at

resp_json = self.req.response.json()
.

This bug would cause exception if we have many requests in a short range of time.

Zoupers added a commit to Zoupers/oapi-sdk-python that referenced this issue Apr 18, 2024
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

No branches or pull requests

1 participant