Skip to content

Commit

Permalink
run.py: __main__実装をmain関数スコープに移動させる (VOICEVOX/voicevox_engine#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
aoirint authored and takana-v committed Nov 28, 2023
1 parent 7e5648f commit efd68e6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def generate_app(
latest_core_version: str,
setting_loader: SettingLoader,
preset_manager: PresetManager,
cancellable_engine: None = None,
root_dir: Optional[Path] = None,
cors_policy_mode: CorsPolicyMode = CorsPolicyMode.localapps,
allow_origin: Optional[List[str]] = None,
Expand Down Expand Up @@ -193,7 +194,7 @@ async def block_origin_middleware(request: Request, call_next):

# @app.on_event("startup")
# async def start_catch_disconnection():
# if args.enable_cancellable_synthesis:
# if cancellable_engine is not None:
# loop = asyncio.get_event_loop()
# _ = loop.create_task(cancellable_engine.catch_disconnection())

Expand Down Expand Up @@ -1111,7 +1112,7 @@ def custom_openapi():
return app


if __name__ == "__main__":
def main() -> None:

output_log_utf8 = os.getenv("VV_OUTPUT_LOG_UTF8", default="")
if output_log_utf8 == "1":
Expand All @@ -1122,8 +1123,6 @@ def custom_openapi():
file=sys.stderr,
)

default_cors_policy_mode = CorsPolicyMode.localapps

parser = argparse.ArgumentParser(description="VOICEVOX のエンジンです。")
parser.add_argument("--host", type=str, default=None, help="接続を受け付けるホストアドレスです。")
parser.add_argument("--port", type=int, default=None, help="接続を受け付けるポート番号です。")
Expand Down Expand Up @@ -1288,6 +1287,7 @@ def custom_openapi():
latest_core_version,
setting_loader,
preset_manager=preset_manager,
cancellable_engine=cancellable_engine,
root_dir=root_dir,
cors_policy_mode=cors_policy_mode,
allow_origin=allow_origin,
Expand All @@ -1296,3 +1296,7 @@ def custom_openapi():
host=host,
port=port,
)


if __name__ == "__main__":
main()

0 comments on commit efd68e6

Please sign in to comment.