Skip to content

Conversation

@mbohlool
Copy link
Contributor

@mbohlool mbohlool commented Nov 11, 2016

PR checklist

  • Read the contribution guildelines.
  • Ran the shell/batch script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates)
  • Filed the PR against the correct branch: master for non-breaking changes and 2.3.0 branch for breaking (non-backward compatible) changes.

Description of the PR

Similar to #4166 adding support for a timeout flag called _request_timeout.

fixes #4169

@wing328
Copy link
Contributor

wing328 commented Nov 11, 2016

Travis CI failed with the following error:

======================================================================
ERROR: test_timeout (tests.test_pet_api.PetApiTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/tests/test_pet_api.py", line 117, in test_timeout
    self.pet_api.add_pet(body=self.pet, _request_timeout=5)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/apis/pet_api.py", line 78, in add_pet
    (data) = self.add_pet_with_http_info(body, **kwargs)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/apis/pet_api.py", line 164, in add_pet_with_http_info
    collection_formats=collection_formats)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/api_client.py", line 326, in call_api
    _return_http_data_only, collection_formats, _preload_content, _Using 3801113795 as seed
request_timeout)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/api_client.py", line 150, in __call_api
    _request_timeout=_request_timeout)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/api_client.py", line 371, in request
    body=body)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/rest.py", line 257, in POST
    body=body)
  File "/home/travis/build/swagger-api/swagger-codegen/samples/client/petstore/python/petstore_api/rest.py", line 136, in request
    if isinstance(_request_timeout, (int, long)):
NameError: name 'long' is not defined

Ref: https://api.travis-ci.org/jobs/175005279/log.txt?deansi=true

Please take a look when you've time.

@mbohlool
Copy link
Contributor Author

I've updated the test and it should pass now.

@wing328 wing328 merged commit 876669c into swagger-api:master Nov 11, 2016
davidgri pushed a commit to davidgri/swagger-codegen that referenced this pull request May 11, 2017
* [Python] Add support for request timeout

* Update python petstore api

* [Python] Add test for request timeout
@wenbochang
Copy link

@mbohlool @wing328 thank you for this feature! is there a way to configure this timeout when generating the client?

We generate like this:

        'docker run -v {output}:/local -v {spec_path}:/spec.yml '
        'swaggerapi/swagger-codegen-cli:v2.3.1 generate -i '
        '/spec.yml -l {language} -o /local '
        '-DpackageName={package_name}')

But it seems the client side just uses urllib3's urlopen and the default timeout for that is infinite

danking added a commit to danking/hail that referenced this pull request Nov 20, 2018
Unfortunately, as far as I can tell, swagger-codgen providss no way
to set a default timeout. Instead, I littered our code with explicit
timeout arguments to k8s API calls.

The best documentation of this feature of swagger-codegen that I have
found is the PR that adds the feature:
swagger-api/swagger-codegen#4173
danking added a commit to hail-is/hail that referenced this pull request Nov 20, 2018
Unfortunately, as far as I can tell, swagger-codgen providss no way
to set a default timeout. Instead, I littered our code with explicit
timeout arguments to k8s API calls.

The best documentation of this feature of swagger-codegen that I have
found is the PR that adds the feature:
swagger-api/swagger-codegen#4173
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Support connection/read timeout

3 participants