Skip to content

[python] Thread pool not closed or handled on client. #6392

@tuxbotix

Description

@tuxbotix
Description

This is a potential issue I found on python client after testing a very badly implemented app which create an API client once in a few seconds!! 😛

The client (api_client.py) creates a ThreadPool on initialization, but it is not closed or cleared. From what I found on little-available documentation on threadPool, it has to be closed.

Suggestions:
Add close() and join() for the "destructor". Once the destructor start to close and join the threads, the system showed no problem after many hours of operations throughout few days.

ref: https://www.codementor.io/lance/simple-parallelism-in-python-du107klle

I can do a PR if this is acceptable.

def __del__(self):
  self.pool.close()
  self.pool.join()
Swagger-codegen version

Spec: 2.0, Codegen: 2.3

Command line used for generation

python client. Nothing special!

swagger-codegen -l python

Steps to reproduce

Try to create client once a second or such small interval (speed up to see results quicker xD), the system will run out of threads. (bad implementations can easily show this.!)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions