Merge lp:~dobey/tarmac/close-conn into lp:tarmac

Proposed by dobey
Status: Work in progress
Proposed branch: lp:~dobey/tarmac/close-conn
Merge into: lp:tarmac
Diff against target: 34 lines (+13/-0)
2 files modified
tarmac/branch.py (+4/-0)
tarmac/tests/test_branch.py (+9/-0)
To merge this branch: bzr merge lp:~dobey/tarmac/close-conn
Reviewer Review Type Date Requested Status
Chris Johnston Needs Fixing
Review via email: mp+221977@code.launchpad.net

Commit message

Disconnect the transport immediately after opening the remote.

Description of the change

This should fix the issue, but there's really no good way to test that it does, without trying it directly. I made a simple hack script to open a remote branch, wait a little over 5 minutes, and then try to do something, to test a couple things for how to fix the bug, and this seemed to work there. So I think it should work in normal use as well.

To post a comment you must log in.
Revision history for this message
Chris Johnston (cjohnston) wrote :

Still getting errors: http://paste.ubuntu.com/7598397/

review: Needs Fixing
Revision history for this message
Chris Johnston (cjohnston) wrote :

At times it seems to be able to complete merges, other times I still end up with the broken pipe.

Revision history for this message
dobey (dobey) wrote :

> At times it seems to be able to complete merges, other times I still end up
> with the broken pipe.

That's certainly odd. If it is still failing in the same way, with this branch, that means the connection is not being disconnected, despite the explicit call being made to disconnect() here. I don't have any good ideas for how else to fix this in tarmac. Digging through the bzrlib code, I did not see a way to force re-establishing the connection.

Unmerged revisions

432. By dobey

Disconnect the transport immediately after opening the remote.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tarmac/branch.py'
2--- tarmac/branch.py 2013-11-07 17:28:53 +0000
3+++ tarmac/branch.py 2014-06-04 01:47:42 +0000
4@@ -37,6 +37,10 @@
5 def __init__(self, lp_branch, config=False, target=None, launchpad=None):
6 self.lp_branch = lp_branch
7 self.bzr_branch = bzr_branch.Branch.open(self.lp_branch.bzr_identity)
8+
9+ # Disconnect to avoid pipe errors when LP drops the connection.
10+ self.bzr_branch._transport.disconnect()
11+
12 if config:
13 self.config = BranchConfig(lp_branch.bzr_identity, config)
14 else:
15
16=== modified file 'tarmac/tests/test_branch.py'
17--- tarmac/tests/test_branch.py 2013-11-07 17:28:53 +0000
18+++ tarmac/tests/test_branch.py 2014-06-04 01:47:42 +0000
19@@ -35,6 +35,15 @@
20 class TestBranch(BranchTestCase):
21 '''Test for Tarmac.branch.Branch.'''
22
23+ @patch('bzrlib.transport.Transport.disconnect')
24+ def test_branch_disconnected(self, mocked):
25+ """Test disconnect is called on the transport after opening."""
26+ tree_dir = os.path.join(self.TEST_ROOT, __name__)
27+ self.add_branch_config(tree_dir)
28+
29+ a_branch = branch.Branch.create(MockLPBranch(tree_dir), self.config)
30+ mocked.assert_called_once_with()
31+
32 def test_create(self):
33 '''Test the creation of a TarmacBranch instance.'''
34 tree_dir = os.path.join(self.TEST_ROOT, 'test_create')

Subscribers

People subscribed via source and target branches