Skip to content

Commit

Permalink
fix: increase default timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-chavez committed Jan 23, 2024
1 parent 176c3fd commit 5c0b8f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions sql/pg_net.sql
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ create or replace function net.http_get(
-- key/values to be included in request headers
headers jsonb default '{}'::jsonb,
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int default 2000
timeout_milliseconds int default 5000
)
-- request_id reference
returns bigint
Expand Down Expand Up @@ -152,7 +152,7 @@ create or replace function net.http_post(
-- key/values to be included in request headers
headers jsonb default '{"Content-Type": "application/json"}'::jsonb,
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int DEFAULT 2000
timeout_milliseconds int DEFAULT 5000
)
-- request_id reference
returns bigint
Expand Down Expand Up @@ -221,7 +221,7 @@ create or replace function net.http_delete(
-- key/values to be included in request headers
headers jsonb default '{}'::jsonb,
-- the maximum number of milliseconds the request may take before being cancelled
timeout_milliseconds int default 2000
timeout_milliseconds int default 5000
)
-- request_id reference
returns bigint
Expand Down
8 changes: 5 additions & 3 deletions test/test_http_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ def test_http_get_timeout_reached(sess):

(request_id,) = sess.execute(text(
"""
select net.http_get(url := 'http://localhost:9999/p/200:b"wait%20for%20three%20seconds"pr,3');
select net.http_get(url := 'http://localhost:9999/p/200:b"wait%20for%20six%20seconds"pr,6');
"""
)).fetchone()

sess.commit()

time.sleep(3.5)
# wait for timeout
time.sleep(6)

(response,) = sess.execute(
text(
Expand Down Expand Up @@ -67,7 +68,8 @@ def test_many_slow_mixed_with_fast(sess):

sess.commit()

time.sleep(3)
# wait for timeout
time.sleep(6)

(status_code,count) = sess.execute(text(
"""
Expand Down

0 comments on commit 5c0b8f4

Please sign in to comment.