Skip to content

Commit

Permalink
Fix #481
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertoPrevato committed Feb 17, 2024
1 parent 59bd3eb commit e856136
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.0.7] - 2024-02-17 :tulip:

- Fixes bug #38, to support properly `list[T]` and `tuple[T]` when defining
query string parameters. Reported by @ranggakd.
- Fixes bug [#38](https://github.com/Neoteroi/BlackSheep-Docs/issues/38),
to support properly `list[T]` and `tuple[T]` when defining query string
parameters. Reported by @ranggakd.
- Passes annotated origin type to build OpenAPI docs (#475), by @tyzhnenko.
- Fixes #481, disabling signal handling by default to avoid negative side
effects. Handling signals is now opt-in and can be achieved using the env
variable `APP_SIGNAL_HANDLER=1`. The `is_stopping` function is modified to
work only when the option is enabled. Issue reported by @netanel-haber.

## [2.0.6] - 2024-01-17 :kr: :heart:

Expand Down
2 changes: 1 addition & 1 deletion blacksheep/server/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def __init__(self) -> None:
self.show_error_details = truthy(os.environ.get("APP_SHOW_ERROR_DETAILS", ""))
self.mount_auto_events = truthy(os.environ.get("APP_MOUNT_AUTO_EVENTS", "1"))
self.use_default_router = truthy(os.environ.get("APP_DEFAULT_ROUTER", "1"))
self.add_signal_handler = truthy(os.environ.get("APP_SIGNAL_HANDLER", "1"))
self.add_signal_handler = truthy(os.environ.get("APP_SIGNAL_HANDLER", ""))
8 changes: 8 additions & 0 deletions blacksheep/server/process.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""
Provides functions related to the server process.
"""

import os
import signal
from typing import TYPE_CHECKING

from blacksheep.utils import truthy

if TYPE_CHECKING:
from blacksheep.server.application import Application

Expand All @@ -15,6 +19,10 @@ def is_stopping() -> bool:
Returns a value indicating whether the server process received a SIGINT or a SIGTERM
signal, and therefore the application is stopping.
"""
if not truthy(os.environ.get("APP_SIGNAL_HANDLER", "")):
raise RuntimeError(
"This function can only be used if the env variable `APP_SIGNAL_HANDLER=1`"
)
return _STOPPING


Expand Down

0 comments on commit e856136

Please sign in to comment.