Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Pass timeout to read and write queries #249

Closed
wants to merge 1 commit into from

Conversation

nikoladsp
Copy link

Closes #

Proposed Changes

Request timeout is passed to read and write calls. Not sure if this is the way you would implement it, but we really needed those so thought to share our current implementation in case you find it useful.

Kindest regards

@nikoladsp nikoladsp changed the title Request timeout passed Pass timeout to read and write queries May 12, 2021
@nikoladsp nikoladsp changed the title Pass timeout to read and write queries feat: Pass timeout to read and write queries May 12, 2021
@bednar
Copy link
Contributor

bednar commented May 12, 2021

Hi @nikoladsp,

thanks for your PR. The issue with passing timeout to HTTP requests was resolved in a Milestone 1.17.0 by #222. Or am I missing something?

Regards

@nikoladsp
Copy link
Author

nikoladsp commented May 12, 2021

Hi,
during the debug I did not see timeout settings were actually applied to the HTTP call, so while calling longer operations, we got timeouts.

Client is instantiated with:

url = "http://localhost:8086"
token = "MyToken"
org = "MyOrg"
timeout = 60000
cli = InfluxDBClient(url=url, token=token, org=org, timeout=timeout)

So when in for example influxdb_client/service/write_service.py in code

return self.api_client.call_api(
            '/api/v2/write', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type=None,  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats,
            urlopen_kw=urlopen_kw)

_request_timeout was set to None, so we used the patch in subject.

Maybe we did something wrong?

Thanks

@bednar
Copy link
Contributor

bednar commented May 12, 2021

The request timeout is set in lower API. Try to add breakpoint here:

_configured_timeout = _request_timeout or self.configuration.timeout

@nikoladsp
Copy link
Author

If I set timeout in InfluxDBClient constructor, should not be passed to the actual self.api_client.call_api call?

Regards

@bednar
Copy link
Contributor

bednar commented May 12, 2021

It is not necessary because it is set in underlaying API:

_configured_timeout = _request_timeout or self.configuration.timeout

Which version of client do you use?

@nikoladsp
Copy link
Author

We tried 1.17.0

@bednar
Copy link
Contributor

bednar commented May 12, 2021

The version 1.17.0 contains fix for passing timeout, see - #221

@nikoladsp
Copy link
Author

Does this applies only to connection timeout or also when reading/writing?

Thanks

@bednar
Copy link
Contributor

bednar commented May 12, 2021

This combines the connect and read timeouts into one. You can also specify timeout as tuple: (25000, 10000) to configure connection and read timeouts differently.

@nikoladsp
Copy link
Author

Many thanks.

In that case we must have some strange issue in our code. I will try to investigate one more time.

Best regards

@bednar
Copy link
Contributor

bednar commented May 25, 2021

Hi @nikoladsp,

did you solve the problem with timeout?

Regards

@bednar
Copy link
Contributor

bednar commented Jun 7, 2021

This PR has been closed because it has not had recent activity. Please reopen if this PR is still important to you and you want to continue with them.

@bednar bednar closed this Jun 7, 2021
@bednar bednar added the wontfix This will not be worked on label Jun 7, 2021
@bednar bednar added this to the 1.19.0 milestone Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants