OpenAPITools / OpenAPITools/openapi-generator
[BUG][PYTHON] The socket is not terminating after being used.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hello Everyone,
I am using the 3.0.3 version of Open API. I am facing an issue because the maximum recursion depth has exceeded, due to the open API client not closing the connection after using it.
OpenAPI yaml file:
openapi: 3.0.3
info:
title: API
version: 1.0.0
paths:
/api/schema/:
get:
operationId: apiSchemaRetrieve
description: |-
OpenApi3 schema for this API. Format can be selected via content negotiation.
- YAML: application/vnd.oai.openapi
- JSON: application/vnd.oai.openapi+json
parameters:
- in: query
name: format
schema:
type: string
enum:
- json
- yaml
- in: query
name: lang
schema:
type: string
enum:
- en
- hi
- mr
tags:
- api
security:
- jwtAuth: []
- {}
responses:
'200':
content:
application/vnd.oai.openapi:
schema:
type: object
additionalProperties: {}
application/yaml:
schema:
type: object
additionalProperties: {}
application/vnd.oai.openapi+json:
schema:
type: object
additionalProperties: {}
application/json:
schema:
type: object
additionalProperties: {}
description: ''
/api/token/refresh/:
post:
operationId: apiTokenRefreshCreate
description: Refresh token create for this API. It will create the new access_token
and refresh token with the valid refresh token.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CustomTokenRefreshRequest'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/CustomTokenRefreshRequest'
multipart/form-data:
schema:
$ref: '#/components/schemas/CustomTokenRefreshRequest'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/RefreshSchema'
description: ''
'403':
description: Forbidden
components:
schemas:
CustomTokenRefreshRequest:
type: object
description: This class represent the custom access_token and refresh token
claims.
properties:
refresh:
type: string
minLength: 1
required:
- refresh
RefreshSchema:
type: object
properties:
access:
type: string
refresh:
type: string
required:
- access
- refresh
securitySchemes:
jwtAuth:
type: http
scheme: bearer
bearerFormat: JWT
I am creating the api instance as follow:
with openapi_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = sse_client.ApiApi(api_client)
api_response = api_instance.api_token_refresh_token()
return api_response.to_dict()
After ending the bock, it should keep a living connection, which causes the problem of maximum recursion depth exceeding.
The socket connection status has been set to 'CLOSE_WAIT'. The connection is not being terminated. After each request, a new client is made and its status is updated to CLOSE_WAIT after execution.
Can anyone assist me in understanding what I am doing incorrectly?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the generated openapi_client.ApiClient context manager and the sse_client.ApiApi.api_token_refresh_token() entry point. Trace how the client and socket are closed after the request, then reproduce repeated calls to check whether CLOSE_WAIT connections accumulate or recursion depth is exceeded. Done means the request lifecycle terminates cleanly without accumulating open connections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100