Skip to content

Commit

Permalink
chore: add server timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
leoprz-wm committed Jan 18, 2023
1 parent 1eb034e commit d59f8db
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ var/
.installed.cfg
*.egg

# pyenv
.python-version
.vscode/
.env

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Pythie serving

## 3.0.0.dev1
## Change
* Add GRPC server timeout

## 3.0.0
## Change
* Upgrade sklearn version to 1.2.0
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
3.0.0.dev1
11 changes: 10 additions & 1 deletion src/pythie_serving/run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import sys
from argparse import ArgumentParser
Expand Down Expand Up @@ -85,8 +86,16 @@ def run():
maximum_concurrent_rpcs=maximum_concurrent_rpcs,
port=ns.port,
)

logger = logging.getLogger("pythie_serving")

server.start()
server.wait_for_termination()

timeout = os.environ.get("GRPC_SERVER_WAIT_TIMEOUT", None)
# wait _for_termination() returns True if a timeout was supplied and it was reached. False otherwise.
timeout_reached = server.wait_for_termination(timeout=float(timeout) if timeout is not None else None)
if timeout_reached:
logger.warning(f"Server shut down after timeout of {timeout} was reached")


if __name__ == "__main__":
Expand Down

0 comments on commit d59f8db

Please sign in to comment.