FIX: windowed app (console=False) sys.stderr=None -> uvicorn logging crash isatty — thay bang devnull
This commit is contained in:
@@ -37,6 +37,16 @@ def _parent_alive(pid):
|
||||
|
||||
def main():
|
||||
os.environ.setdefault("SF_DESKTOP", "1")
|
||||
|
||||
# Windowed app (engine.spec console=False): Windows khong tao console ->
|
||||
# sys.stdout/sys.stderr = None -> uvicorn logging crash
|
||||
# ('NoneType' object has no attribute 'isatty'). Thay bang file rong de
|
||||
# uvicorn (StreamHandler/isatty) luon co stream hop le.
|
||||
if sys.stdout is None:
|
||||
sys.stdout = open(os.devnull, "w")
|
||||
if sys.stderr is None:
|
||||
sys.stderr = open(os.devnull, "w")
|
||||
|
||||
port = _pick_port()
|
||||
os.environ["SF_PORT"] = str(port)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user