Skip to content

Commit

Permalink
Call PBClientFactory.clientConnectionLost to break a reference cycle.
Browse files Browse the repository at this point in the history
This is the same basic problem as twisted@5f07ad4

connectedServerAndClient previously created its own Broker object.
Now that connectServerAndClient takes a PBClientFactory instance, its
clientConnectionLost method must also be called to remove its _broker
attribute, breaking the PBClientFactory <-> _broker and
RemoteReference <-> broker cycles.
  • Loading branch information
markrwilliams committed Aug 28, 2016
1 parent ee8f194 commit 3ae3e9b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/twisted/spread/test/test_pb.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,20 @@ def connectServerAndClient(test, serverFactory, clientFactory):
def maybeDisconnect(broker):
if not broker.disconnected:
broker.connectionLost(failure.Failure(main.CONNECTION_DONE))


def disconnectClientFactory():
# There's no connector, just a FileWrapper mediated by the
# IOPump. Fortunately PBClientFactory.clientConnectionLost
# doesn't do anything with the connector so we can get away
# with passing None here.
clientFactory.clientConnectionLost(
connector=None,
reason=failure.Failure(main.CONNECTION_DONE))

test.addCleanup(maybeDisconnect, clientBroker)
test.addCleanup(maybeDisconnect, serverBroker)
test.addCleanup(disconnectClientFactory)
# Establish the connection
pump.pump()
return clientBroker, serverBroker, pump
Expand Down Expand Up @@ -405,6 +417,7 @@ def remote_giveMeCache(self, st):


class NewStyleTests(unittest.SynchronousTestCase):

def setUp(self):
"""
Create a pb server using L{Echoer} protocol and connect a client to it.
Expand Down

0 comments on commit 3ae3e9b

Please sign in to comment.