Skip to content

Commit df32e4b

Browse files
committed
🚚 Move reactor initialisation
1 parent 00b8dc7 commit df32e4b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

apricot/apricot_server.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ def __init__(
7474
observer.start()
7575
self.logger = Logger()
7676

77+
# Load the Twisted reactor
78+
self.reactor = cast("IReactorCore", reactor)
79+
7780
# Initialise the UID cache
7881
uid_cache: UidCache
7982
if redis_host and redis_port:
@@ -90,7 +93,7 @@ def __init__(
9093
# Initialise the appropriate OAuth client
9194
try:
9295
self.logger.debug(
93-
"Creating an OAuthClient for the '{backend}' backend.",
96+
"Creating an OAuthClient for the {backend} backend.",
9497
backend=backend.value,
9598
)
9699
oauth_backend = OAuthClientMap[backend]
@@ -104,7 +107,7 @@ def __init__(
104107
**{k: v for k, v in kwargs.items() if k in oauth_backend_args},
105108
)
106109
except Exception as exc:
107-
msg = f"Could not construct an OAuth client for the '{backend.value}' backend.\n{exc!s}"
110+
msg = f"Could not construct an OAuth client for the {backend.value} backend.\n{exc!s}"
108111
raise ValueError(msg) from exc
109112

110113
# Initialise the OAuth data adaptor
@@ -136,7 +139,7 @@ def __init__(
136139

137140
# Attach a listening endpoint
138141
self.logger.info("Listening for LDAP requests on port {port}.", port=port)
139-
endpoint: IStreamServerEndpoint = serverFromString(reactor, f"tcp:{port}")
142+
endpoint: IStreamServerEndpoint = serverFromString(self.reactor, f"tcp:{port}")
140143
endpoint.listen(factory)
141144

142145
# Attach a listening endpoint
@@ -152,14 +155,11 @@ def __init__(
152155
port=tls_port,
153156
)
154157
ssl_endpoint: IStreamServerEndpoint = serverFromString(
155-
reactor,
158+
self.reactor,
156159
f"ssl:{tls_port}:privateKey={quoteStringArgument(tls_private_key)}:certKey={quoteStringArgument(tls_certificate)}",
157160
)
158161
ssl_endpoint.listen(factory)
159162

160-
# Load the Twisted reactor
161-
self.reactor = cast("IReactorCore", reactor)
162-
163163
def run(self: Self) -> None:
164164
"""Start the Twisted reactor."""
165165
self.reactor.run()

0 commit comments

Comments
 (0)