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

Commit

Permalink
Do not instantiate recv, it is already an instance.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clokep committed Mar 8, 2021
1 parent db17a67 commit 315061f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions synapse/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ def __init__(
def resolveHostName(
self, recv: IResolutionReceiver, hostname: str, portNumber: int = 0
) -> IResolutionReceiver:

r = recv()
addresses = [] # type: List[IAddress]

def _callback() -> None:
r.resolutionBegan(None)
recv.resolutionBegan(None)

has_bad_ip = False
for i in addresses:
Expand All @@ -176,8 +174,8 @@ def _callback() -> None:
# valid results.
if not has_bad_ip:
for i in addresses:
r.addressResolved(i)
r.resolutionComplete()
recv.addressResolved(address)
recv.resolutionComplete()

@provider(IResolutionReceiver)
class EndpointReceiver:
Expand All @@ -197,7 +195,7 @@ def resolutionComplete() -> None:
EndpointReceiver, hostname, portNumber=portNumber
)

return r
return recv


@implementer(ISynapseReactor)
Expand Down

0 comments on commit 315061f

Please sign in to comment.