Skip to content

Commit

Permalink
Use is_true
Browse files Browse the repository at this point in the history
  • Loading branch information
amh4r committed Sep 17, 2024
1 parent 457b171 commit c0f28a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 2 additions & 3 deletions inngest/_internal/comm_lib/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ def __init__(
framework: server_lib.Framework,
functions: list[function.Function],
) -> None:
self._allow_in_band_sync = env_lib.is_truthy(
# TODO: Default to true once in-band syncing is stable
self._allow_in_band_sync = env_lib.is_true(
const.EnvKey.ALLOW_IN_BAND_SYNC,
# TODO: Default to true once in-band syncing is stable
default=False,
)
self._client = client
self._mode = client._mode
Expand Down
13 changes: 11 additions & 2 deletions inngest/_internal/env_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,19 @@ def get_url(
return parsed


def is_truthy(env_var: const.EnvKey, default: bool = False) -> bool:
def is_true(env_var: const.EnvKey) -> bool:
val = os.getenv(env_var.value)
if val is None:
return default
return False
val = val.strip()

return val.lower() in ("true", "1")


def is_truthy(env_var: const.EnvKey) -> bool:
val = os.getenv(env_var.value)
if val is None:
return False
val = val.strip()

if val.lower() in ("false", "0", ""):
Expand Down

0 comments on commit c0f28a6

Please sign in to comment.