Skip to content

Commit 5de334e

Browse files
committed
set default timeout for path watched to 30 seconds
1 parent 3dfb25b commit 5de334e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

reddit_decider/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from copy import deepcopy
44
from dataclasses import dataclass
5+
from datetime import timedelta
56
from enum import Enum
67
from typing import Any
78
from typing import Callable
@@ -1193,9 +1194,10 @@ def decider_client_from_config(
11931194
``path`` (optional)
11941195
The path to the experiment configuration file generated by the
11951196
experiment configuration fetcher daemon.
1197+
Defaults to :code:`"/var/local/experiments.json"`.
11961198
``timeout`` (optional)
1197-
The time that we should wait for the file specified by ``path`` to
1198-
exist. Defaults to `None` which is not blocking.
1199+
The time that we should wait for the file specified by ``path`` to exist.
1200+
Defaults to blocking for :code:`30` seconds.
11991201
``backoff`` (optional)
12001202
The base amount of time for exponential backoff when trying to find the
12011203
experiments config file. Defaults to no backoff between tries.
@@ -1215,7 +1217,7 @@ def decider_client_from_config(
12151217
{
12161218
config_prefix: {
12171219
"path": config.Optional(config.String, default="/var/local/experiments.json"),
1218-
"timeout": config.Optional(config.Timespan),
1220+
"timeout": config.Optional(config.Timespan, default=timedelta(seconds=30)),
12191221
"backoff": config.Optional(config.Timespan),
12201222
}
12211223
},

tests/decider_tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ def setUp(self):
8888
self.mock_span = mock.MagicMock(spec=ServerSpan)
8989
self.mock_span.context = None
9090

91-
def test_make_clients(self, file_watcher_mock):
91+
def test_make_client_without_timeout_set(self, file_watcher_mock):
9292
with create_temp_config_file({}) as f:
9393
decider_ctx_factory = decider_client_from_config(
9494
{"experiments.path": f.name}, self.event_logger
9595
)
9696
self.assertIsInstance(decider_ctx_factory, DeciderContextFactory)
9797
file_watcher_mock.assert_called_once_with(
98-
path=f.name, parser=init_decider_parser, timeout=None, backoff=None
98+
path=f.name, parser=init_decider_parser, timeout=30.0, backoff=None
9999
)
100100

101101
def test_timeout(self, file_watcher_mock):

0 commit comments

Comments
 (0)