Project

General

Profile

Actions

Feature #16673

open

total_timeout for Net::HTTP

Added by mohamedhafez (Mohamed Hafez) almost 5 years ago. Updated almost 5 years ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:97362]

Description

Net::HTTP allows setting open_timeout and read_timeout, but sometimes I just want to make sure an API call will finish within a set amount of time, and am not concerned with how long opening the connection takes and reading the connection takes individually, as long as the total is beneath a certain amount. Yes, one could set open_timeout + read_timeout to be equal to the maximum time they are willing to wait, but then for example if opening the socket happens almost immediately, I may get a read timeout when I am still willing to wait a bit longer (this is the case for the service I run, where we hit an external API that occasionally takes 60s to respond, and am trying to catch some of those longer running requests. it also occasionally takes over 5 seconds to open a connection, so I can't make open_timeout minimal either). In other languages, setting a total timeout is possible, like for example Java's HttpRequest.

My intern @LevonAr (Levon Arabyan ) is willing to work on this, and put in a total_timeout option in a way that doesn't interfere with the current functioning of open_timeout and read_timeout. Would a patch to put in this feature be accepted?

Updated by prajjwal (Prajjwal Singh) almost 5 years ago

+1. This is something I'd love to see implemented because this is actually the most common use case for me.

Could be implemented in a backwards compatible way (set open_timeout and read_timeout to total_timeout and abort appropriately).

Actions #2

Updated by LevonAr (Levon Arabyan ) almost 5 years ago

  • Tracker changed from Feature to Bug
  • Backport set to 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
Actions #3

Updated by LevonAr (Levon Arabyan ) almost 5 years ago

  • Tracker changed from Bug to Feature
  • Backport deleted (2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0