bravado
bravado copied to clipboard
OverflowError: timeout value is too large
I encountered the captioned error when running the following script, regardless python versions (3.8/3.7 were both tried).
from bravado.fido_client import FidoClient
from bravado.client import SwaggerClient
http_client = FidoClient()
client = SwaggerClient.from_url(
'http://petstore.swagger.io/v2/swagger.json',
http_client=http_client,
)
pet = client.pet.getPetById(petId=1).response().result
The trace stack:
Traceback (most recent call last): File "C:/async_test.py", line 52, in
http_client=http_client, File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\bravado\client.py", line 98, in from_url spec_dict = loader.load_spec(spec_url) File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\bravado\swagger_model.py", line 104, in load_spec self.request_headers, File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\bravado\http_future.py", line 270, in result incoming_response = self._get_incoming_response(timeout) File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\bravado\http_future.py", line 124, in wrapper return func(self, *args, **kwargs) File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\bravado\http_future.py", line 291, in _get_incoming_response inner_response = self.future.result(timeout=timeout) File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\bravado\fido_client.py", line 127, in result return self._eventual_result.wait(timeout=timeout) File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\crochet_eventloop.py", line 239, in wait result = self._result(timeout) File "C:\ProgramData\Anaconda3\envs\hft\lib\site-packages\crochet_eventloop.py", line 197, in _result self._result_set.wait(timeout) File "C:\ProgramData\Anaconda3\envs\hft\lib\threading.py", line 552, in wait signaled = self._cond.wait(timeout) File "C:\ProgramData\Anaconda3\envs\hft\lib\threading.py", line 300, in wait gotit = waiter.acquire(True, timeout) OverflowError: timeout value is too large Process finished with exit code 1
I need to use the async feature of this library, but how can I fix this issue? Please help!
@TristanWYL I'm unsure about the error as it is the first time I see something similar.
I've tried to reproduce your script on my laptop (MacOS) and I failed :(
Python 3.9.0 (default, Oct 19 2020, 00:46:30)
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from bravado.fido_client import FidoClient
>>> from bravado.client import SwaggerClient
>>> client = SwaggerClient.from_url('http://petstore.swagger.io/v2/swagger.json', http_client=FidoClient())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/maci/Desktop/venv39/lib/python3.9/site-packages/bravado/client.py", line 98, in from_url
spec_dict = loader.load_spec(spec_url)
File "/Users/maci/Desktop/venv39/lib/python3.9/site-packages/bravado/swagger_model.py", line 101, in load_spec
response = request(
File "/Users/maci/Desktop/venv39/lib/python3.9/site-packages/bravado/http_future.py", line 282, in result
raise make_http_exception(response=incoming_response)
bravado.exception.HTTPFound: 302 b'Moved Temporarily'
according to the error seems that the fido client is reacting differently between different platforms.
NOTE: The FidoClient
is a wrapper around https://github.com/Yelp/fido , so it might be worth asking in there.
Few notes that might help you workaround the issue:
- The spec link is an
http
link which redirects you to thehttps
version, so maybe that can be an issue. I don't recall a direct way to have a FidoClient which accept redirects though :(
>>> try:
... client = SwaggerClient.from_url('http://petstore.swagger.io/v2/swagger.json', http_client=FidoClient())
... except Exception as e:
... print(e.response.headers)
...
{'Server': 'awselb/2.0', 'Date': 'Wed, 18 Nov 2020 19:18:23 GMT', 'Content-Type': 'text/html', 'Location': 'https://petstore.swagger.io:443/v2/swagger.json'}
- At the current state Python2 and 3.5 are deprecated, if you need an async client I would recommend using
bravado-asyncio
as it requires much less dependencies to install, is based on asyncio so more friendly on resource usage and is more compatible with the configurations of theRequestsClient
.