This commit is contained in:
Mohammed 2025-02-20 12:34:48 -07:00 committed by GitHub
commit a26d8c26b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -126,14 +126,16 @@ class DaphneProcess(multiprocessing.Process):
port it ends up listening on back to the parent process.
"""
def __init__(self, host, get_application, kwargs=None, setup=None, teardown=None):
def __init__(
self, host, get_application, kwargs=None, setup=None, teardown=None, port=None
):
super().__init__()
self.host = host
self.get_application = get_application
self.kwargs = kwargs or {}
self.setup = setup
self.teardown = teardown
self.port = multiprocessing.Value("i")
self.port = multiprocessing.Value("i", port if port is not None else 0)
self.ready = multiprocessing.Event()
self.errors = multiprocessing.Queue()
@ -153,7 +155,9 @@ class DaphneProcess(multiprocessing.Process):
try:
# Create the server class
endpoints = build_endpoint_description_strings(host=self.host, port=0)
endpoints = build_endpoint_description_strings(
host=self.host, port=self.port.value
)
self.server = Server(
application=application,
endpoints=endpoints,