Skip to content

Instantly share code, notes, and snippets.

@fpaupier
Created August 8, 2021 10:40
Show Gist options
  • Save fpaupier/a6555a4956f8959c1a58acbe0add97a4 to your computer and use it in GitHub Desktop.
Save fpaupier/a6555a4956f8959c1a58acbe0add97a4 to your computer and use it in GitHub Desktop.
A non working gRPC server init
def main():
"""
Inspired from https://github.com/grpc/grpc/blob/master/examples/python/multiprocessing/server.py
"""
logger.info(f'Initializing server with {NUM_WORKERS} workers')
with _reserve_port() as port:
bind_address = f"[::]:{port}"
logger.info(f"Binding to {bind_address}")
sys.stdout.flush()
workers = []
for _ in range(NUM_WORKERS):
worker = multiprocessing.Process(target=_run_server,
args=(bind_address,))
worker.start()
workers.append(worker)
for worker in workers:
worker.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment