Rev 4859: Change the connect-to-bzr test so that it cleans itself up. in http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-test-cleanups
John Arbash Meinel
john at arbash-meinel.com
Thu Dec 3 20:23:11 GMT 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1.0b4-win32-test-cleanups
------------------------------------------------------------
revno: 4859
revision-id: john at arbash-meinel.com-20091203202257-jly7wpd6fa933je3
parent: john at arbash-meinel.com-20091203200529-no7ltq6gew22392l
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1.0b4-win32-test-cleanups
timestamp: Thu 2009-12-03 14:22:57 -0600
message:
Change the connect-to-bzr test so that it cleans itself up.
We have to tell the transport to disconnect, which unfortunately means
poking at private variables, but only for this test.
This still leaves 2 non-main threads active and 'leaked', but that might
actually be paramiko. Hard to tell for sure.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_transport.py'
--- a/bzrlib/tests/test_transport.py 2009-09-22 04:25:05 +0000
+++ b/bzrlib/tests/test_transport.py 2009-12-03 20:22:57 +0000
@@ -908,6 +908,7 @@
# executes commands, and manage the hooking up of stdin/out/err to the
# SSH channel ourselves. Surely this has already been implemented
# elsewhere?
+ started = []
class StubSSHServer(StubServer):
test = self
@@ -933,10 +934,12 @@
(channel.recv, proc.stdin.write, proc.stdin.close),
(proc.stdout.read, channel.sendall, channel.close),
(proc.stderr.read, channel.sendall_stderr, channel.close)]
+ started.append(proc)
for read, write, close in file_functions:
t = threading.Thread(
target=ferry_bytes, args=(read, write, close))
t.start()
+ started.append(t)
return True
@@ -967,3 +970,13 @@
self.assertEqual(
['%s serve --inet --directory=/ --allow-writes' % bzr_remote_path],
self.command_executed)
+ # Make sure to disconnect, so that the remote process can stop, and we
+ # can cleanup. Then pause the test until everything is shutdown
+ t._client._medium.disconnect()
+ if not started:
+ return
+ # First wait for the subprocess
+ started[0].wait()
+ # And the rest are threads
+ for t in started[1:]:
+ t.join()
More information about the bazaar-commits
mailing list