Rev 4910: Just merge in the -Dnoretry code so we can use it in read-reconnect. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-categorize-requests-819604
John Arbash Meinel
john at arbash-meinel.com
Mon Oct 10 12:59:01 UTC 2011
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-categorize-requests-819604
------------------------------------------------------------
revno: 4910 [merge]
revision-id: john at arbash-meinel.com-20111010125843-ntwjed4qrt2h9xaq
parent: john at arbash-meinel.com-20111010124110-fxw5migxcbccs89a
parent: john at arbash-meinel.com-20111010124914-12bq3apx7207nlbc
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-categorize-requests-819604
timestamp: Mon 2011-10-10 14:58:43 +0200
message:
Just merge in the -Dnoretry code so we can use it in read-reconnect.
modified:
bzrlib/help_topics/en/debug-flags.txt debugflags.txt-20090312050229-rdspqbqq4fzbjtpe-1
bzrlib/smart/client.py client.py-20061116014825-2k6ada6xgulslami-1
bzrlib/tests/test_smart_transport.py test_ssh_transport.py-20060608202016-c25gvf1ob7ypbus6-2
-------------- next part --------------
=== modified file 'bzrlib/help_topics/en/debug-flags.txt'
--- a/bzrlib/help_topics/en/debug-flags.txt 2010-01-05 04:30:07 +0000
+++ b/bzrlib/help_topics/en/debug-flags.txt 2011-10-10 12:49:14 +0000
@@ -24,6 +24,8 @@
-Dindex Trace major index operations.
-Dknit Trace knit operations.
-Dlock Trace when lockdir locks are taken or released.
+-Dnoretry If a connection is reset, fail immediately rather than
+ retrying the request.
-Dprogress Trace progress bar operations.
-Dmerge Emit information for debugging merges.
-Dno_apport Don't use apport to report crashes.
=== modified file 'bzrlib/smart/client.py'
--- a/bzrlib/smart/client.py 2011-10-08 10:23:15 +0000
+++ b/bzrlib/smart/client.py 2011-10-10 12:49:14 +0000
@@ -17,6 +17,7 @@
import bzrlib
from bzrlib.smart import message, protocol
from bzrlib import (
+ debug,
errors,
hooks,
trace,
@@ -237,13 +238,14 @@
# Connection is dead, so close our end of it.
self.client._medium.reset()
- if self.body_stream is not None:
+ if (('noretry' in debug.debug_flags)
+ or self.body_stream is not None):
# We can't restart a body_stream that has been partially
# consumed, so we don't retry.
raise
+ trace.warning('ConnectionReset calling %r, retrying'
+ % (self.method,))
trace.log_exception_quietly()
- trace.warning('ConnectionReset calling %s, retrying'
- % (self.method,))
encoder, response_handler = self._construct_protocol(
protocol_version)
self._send_no_retry(encoder)
=== modified file 'bzrlib/tests/test_smart_transport.py'
--- a/bzrlib/tests/test_smart_transport.py 2011-10-10 12:06:48 +0000
+++ b/bzrlib/tests/test_smart_transport.py 2011-10-10 12:49:14 +0000
@@ -28,6 +28,7 @@
import bzrlib
from bzrlib import (
bzrdir,
+ debug,
errors,
osutils,
tests,
@@ -3474,6 +3475,18 @@
],
vendor.calls)
+ def test__send_disabled_retry(self):
+ debug.debug_flags.add('noretry')
+ output, vendor, smart_client = self.make_client_with_failing_medium()
+ smart_request = client._SmartClientRequest(smart_client, 'hello', ())
+ self.assertRaises(errors.ConnectionReset, smart_request._send, 3)
+ self.assertEqual(
+ [('connect_ssh', 'a user', 'a pass', 'a host', 'a port',
+ ['bzr', 'serve', '--inet', '--directory=/', '--allow-writes']),
+ ('close',),
+ ],
+ vendor.calls)
+
class LengthPrefixedBodyDecoder(tests.TestCase):
More information about the bazaar-commits
mailing list