mirror of
https://github.com/django/daphne.git
synced 2025-04-17 23:32:12 +03:00
allow assigning a port in DaphneProcess
This commit is contained in:
parent
630caed915
commit
8d87442ed1
|
@ -126,14 +126,14 @@ 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 +153,7 @@ 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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user