@danhachuel/thunderbolt 0.5.49 → 0.5.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import io
|
|
4
4
|
import os
|
|
5
|
+
import signal
|
|
5
6
|
import sys
|
|
6
7
|
|
|
7
8
|
# Este ficheiro é o primeiro módulo Python executado pelo launcher. As
|
|
@@ -28,6 +29,26 @@ def _utf8_stream(stream: object) -> object:
|
|
|
28
29
|
sys.stdout = _utf8_stream(sys.stdout)
|
|
29
30
|
sys.stderr = _utf8_stream(sys.stderr)
|
|
30
31
|
|
|
32
|
+
|
|
33
|
+
def _custom_sigint_handler(signum: int, frame: object) -> None:
|
|
34
|
+
"""Encerrar sem executar ``server.stop``/Click do handler do Streamlit."""
|
|
35
|
+
print("\nEncerrando servidor...", file=sys.stderr, flush=True)
|
|
36
|
+
raise SystemExit(0)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
_original_signal = signal.signal
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _protected_signal(signum: signal.Signals, handler: object) -> object:
|
|
43
|
+
"""Não permitir que Streamlit substitua o handler seguro de SIGINT."""
|
|
44
|
+
if signum == signal.SIGINT:
|
|
45
|
+
return _original_signal(signal.SIGINT, _custom_sigint_handler)
|
|
46
|
+
return _original_signal(signum, handler)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
_original_signal(signal.SIGINT, _custom_sigint_handler)
|
|
50
|
+
signal.signal = _protected_signal
|
|
51
|
+
|
|
31
52
|
from streamlit.web.cli import main # noqa: E402
|
|
32
53
|
|
|
33
54
|
if __name__ == "__main__":
|