如何为Swagger生成的Python API客户端设置超时?
默认情况下,Swagger Codegen Python客户端的超时时间很高,我想设置其值。
By default, the swagger codegen python client has a high timeout and I would like to set its value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,您可以使用以下参数来配置请求:
_request_timeout
(int)此请求的超时设置。如果提供了一个数字,则将是总请求超时。它也可以是(连接,读)超时的一对(元组)。_PRELOAD_CONTENT
(bool)如果false,则urllib3.httpresponse对象将在不读取/解码响应数据的情况下返回。默认是正确的。_return_http_data_only
(bool)如果为true,请返回响应数据,而无需头部状态代码和标题如何使用它们:
where:
myapicontroller
是由Swagger Code创建的控制器类, >/Controller 客户端的文件夹myData
和my_apikey
是您可以在请求中发送的数据的示例。您可能不需要它们,这取决于您的端点定义。Turns out you can use the following parameters to configure the request:
_request_timeout
(int) Timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts._preload_content
(bool) If False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True._return_http_data_only
(bool) If True, returns response data without head status code and headersHow to use them:
Where:
MyAPIcontroller
is the controller class created by Swagger codegen in the/controllers
folder of your clientMyData
andmy_apikey
are examples of data you can send in your request. You may not need them, it depends on your endpoint definition.