This repository was archived by the owner on Jan 5, 2024. It is now read-only.
File tree 3 files changed +14
-12
lines changed
3 files changed +14
-12
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ class ErrorMessage(BaseMessage):
60
60
ErrorCode .unexpected : 'unexpected' ,
61
61
ErrorCode .bad_request : 'bad request' ,
62
62
ErrorCode .network_error : 'network error' ,
63
+ ErrorCode .unhealthy : 'unhealthy error' ,
63
64
ErrorCode .fatal : 'fatal protocol error'
64
65
}
65
66
Original file line number Diff line number Diff line change 23
23
import json
24
24
import logging
25
25
26
+ from ..errors import ProtocolError
27
+ from ..errors import TimeoutError
28
+
26
29
import tornado .gen
27
30
import tornado .ioloop
28
31
@@ -86,7 +89,7 @@ def _register(attempt_counter=0):
86
89
headers = {'as' : 'json' },
87
90
attempt_times = 1 ,
88
91
)
89
- except Exception as e :
92
+ except ( ProtocolError , TimeoutError ) as e :
90
93
attempt_counter += 1
91
94
log .error ('Failed to register with Hyperbahn: %s' , e )
92
95
else :
@@ -95,14 +98,14 @@ def _register(attempt_counter=0):
95
98
log .error ('Failed to register with Hyperbahn: %s' , response )
96
99
else :
97
100
attempt_counter = 0
98
- finally :
99
- delay_time = DEFAULT_ERROR_RETRY_TIMES [
100
- min (attempt_counter , len (DEFAULT_ERROR_RETRY_TIMES ) - 1 )
101
- ]
102
- tornado .ioloop .IOLoop .current ().call_later (
103
- delay = delay_time ,
104
- callback = lambda : _register (attempt_counter ),
105
- )
101
+
102
+ delay_time = DEFAULT_ERROR_RETRY_TIMES [
103
+ min (attempt_counter , len (DEFAULT_ERROR_RETRY_TIMES ) - 1 )
104
+ ]
105
+ tornado .ioloop .IOLoop .current ().call_later (
106
+ delay = delay_time ,
107
+ callback = lambda : _register (attempt_counter ),
108
+ )
106
109
107
110
return _register ()
108
111
Original file line number Diff line number Diff line change 18
18
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
# THE SOFTWARE.
20
20
21
- from mock import patch
22
21
import pytest
23
22
24
23
from tchannel .errors import ConnectionClosedError
@@ -61,6 +60,5 @@ def test_request():
61
60
def test_register ():
62
61
channel = TChannel (name = 'test' )
63
62
64
- with patch ( 'tchannel.tornado.hyperbahn.log' ) as mock_logger :
63
+ with pytest . raises ( ConnectionClosedError ) :
65
64
yield hyperbahn .advertise (channel , 'foo' , ['127.0.0.1:23000' ])
66
- assert mock_logger .error .called
You can’t perform that action at this time.
0 commit comments