-
Notifications
You must be signed in to change notification settings - Fork 213
Only 2 Secound Timout for Rest Calls #353
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
Comments
I've been checking how to make the maximum number for the timeout larger. One way could be to in this line of the function: timeout_in_ns = int(self.timeout * _TO_NANOSECONDS) Use timeout_in_ns = long(self.timeout * _TO_NANOSECONDS) So now the function would look like: def _handle_timeout(self, waiter, reason):
timeout_in_ns = long(self.timeout * _TO_NANOSECONDS) # Switch to 'long' for larger timeouts
log.debug("Waiting for up to %.2fs for %s", self.timeout, reason, extra={"sock": self})
started = time.time()
result = waiter(timeout_in_ns, TimeUnit.NANOSECONDS)
log.debug("Completed in %.2fs", time.time() - started, extra={"sock": self})
if not result:
if self.timeout == 0:
raise error(errno.ETIMEDOUT, "Connection timed out")
else:
raise timeout(errno.ETIMEDOUT, "timed out")
return result This would increase the limit for the timeout to pretty much infinity as much as your device has enough memory, or the number isn't big enough to cause any issues with the library or Jython in general. Maybe it could be a good idea to add something like a limit to make it more difficult for something to end up breaking: def _handle_timeout(self, waiter, reason):
timeout_in_ns = long(self.timeout * _TO_NANOSECONDS) # Use 'long' for larger timeouts
max_timeout_in_ns = long(2.592e+15) # Maximum nanoseconds, equal to the number of nanoseconds in a 30-day month
if timeout_in_ns > max_timeout_in_ns:
raise ValueError("Timeout exceeds 30-day month limit")
log.debug("Waiting for up to %.2fs for %s", self.timeout, reason, extra={"sock": self})
started = time.time()
result = waiter(timeout_in_ns, TimeUnit.NANOSECONDS)
log.debug("Completed in %.2fs", time.time() - started, extra={"sock": self})
if not result:
if self.timeout == 0:
raise error(errno.ETIMEDOUT, "Connection timed out")
else:
raise timeout(errno.ETIMEDOUT, "timed out")
return result I still need to check that using |
Hi everyone,
I have an issue with the timeout for rest calls.
The issue I'm having is in Lib/_socket.py 858 (_handle_timeout).
The tool I'm using is running Python 2 and has a max int of 2147483647. This will give me only 2.14 seconds of timeout.
If I give the int() function more than the max int it will be automatically reduced.
Does anyone have a solution that can be implemented in the Jython repo?
Here a screenshot from the tool:

Thanks :)
The text was updated successfully, but these errors were encountered: