Skip to content

Commit

Permalink
Allow Tornando workers to be specified (kubeflow#512)
Browse files Browse the repository at this point in the history
* Fix typo in resources

* Allow number of workers to be specified for Tornando

* remove comment
  • Loading branch information
ukclivecox authored and k8s-ci-robot committed Nov 1, 2019
1 parent 2bff897 commit 5896d33
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions python/kfserving/kfserving/kfserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@
help='The HTTP Port listened to by the model server.')
parser.add_argument('--grpc_port', default=DEFAULT_GRPC_PORT, type=int,
help='The GRPC Port listened to by the model server.')
parser.add_argument('--workers', default=0, type=int,
help='The number of works to fork')
args, _ = parser.parse_known_args()

logging.basicConfig(level=constants.KFSERVING_LOGLEVEL)


class KFServer():
def __init__(self, http_port: int = args.http_port,
grpc_port: int = args.grpc_port):
grpc_port: int = args.grpc_port,
workers: int = args.workers):
self.registered_models = {}
self.http_port = http_port
self.grpc_port = grpc_port
self.workers = workers
self._http_server = None

def create_application(self):
Expand All @@ -68,7 +72,8 @@ def start(self, models: List[KFModel]):

logging.info("Listening on port %s", self.http_port)
self._http_server.bind(self.http_port)
self._http_server.start(0) # Forks workers equal to host's cores
logging.info("Will fork %d workers", self.workers)
self._http_server.start(self.workers)
tornado.ioloop.IOLoop.current().start()

def register_model(self, model: KFModel):
Expand Down

0 comments on commit 5896d33

Please sign in to comment.