Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 315061f

Browse files
committed
Do not instantiate recv, it is already an instance.
This just happens to work since the default implementation (via the HostnameEndpoint) happens to create a class that only has static methods, then passes the class (without instantiating it), presumedly to save memory.
1 parent db17a67 commit 315061f

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

synapse/http/client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,10 @@ def __init__(
151151
def resolveHostName(
152152
self, recv: IResolutionReceiver, hostname: str, portNumber: int = 0
153153
) -> IResolutionReceiver:
154-
155-
r = recv()
156154
addresses = [] # type: List[IAddress]
157155

158156
def _callback() -> None:
159-
r.resolutionBegan(None)
157+
recv.resolutionBegan(None)
160158

161159
has_bad_ip = False
162160
for i in addresses:
@@ -176,8 +174,8 @@ def _callback() -> None:
176174
# valid results.
177175
if not has_bad_ip:
178176
for i in addresses:
179-
r.addressResolved(i)
180-
r.resolutionComplete()
177+
recv.addressResolved(address)
178+
recv.resolutionComplete()
181179

182180
@provider(IResolutionReceiver)
183181
class EndpointReceiver:
@@ -197,7 +195,7 @@ def resolutionComplete() -> None:
197195
EndpointReceiver, hostname, portNumber=portNumber
198196
)
199197

200-
return r
198+
return recv
201199

202200

203201
@implementer(ISynapseReactor)

0 commit comments

Comments
 (0)