Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only catch Exception and subclasses in Connection and Channel, fixes #23



Upgrade to chai 0.2.0
haigha 0.5.6
  • Loading branch information...
commit 06901147156a6ab5ed2ffa71c5d99fea72467361 1 parent 73cfdb3
@awestendorf awestendorf authored
View
8 CHANGELOG
@@ -1,3 +1,11 @@
+0.5.6
+=====
+
+Only catch Exception subclasses in Connection and Channel. Fixes issue #23.
+
+Update to Chai 0.2.0
+
+
0.5.5
=====
View
2  DOCUMENTATION.rst
@@ -2,7 +2,7 @@
Haigha
======
-:Version: 0.5.3
+:Version: 0.5.6
:Download: http://pypi.python.org/pypi/haigha
:Source: https://github.com/agoragames/haigha
View
2  README.rst
@@ -2,7 +2,7 @@
Haigha - AMQP libevent Python client
=====================================
-:Version: 0.5.5
+:Version: 0.5.6
:Download: http://pypi.python.org/pypi/haigha
:Source: https://github.com/agoragames/haigha
:Keywords: python, amqp, rabbitmq, event, libevent, gevent
View
2  development.txt
@@ -1,4 +1,4 @@
-r requirements.txt
-chai>=0.1.22
+chai>=0.2.0
unittest2
View
2  haigha/__init__.py
@@ -4,4 +4,4 @@
https://github.com/agoragames/haigha/blob/master/LICENSE.txt
'''
-__version__ = "0.5.5"
+__version__ = "0.5.6"
View
2  haigha/channel.py
@@ -206,7 +206,7 @@ def process_frames(self):
self.dispatch( frame )
except ProtocolClass.FrameUnderflow:
return
- except:
+ except Exception:
# Spec says that channel should be closed if there's a framing error.
# Unsure if we can send close if the current exception is transport
# level (e.g. gevent.GreenletExit)
View
2  haigha/connection.py
@@ -209,7 +209,7 @@ def disconnect(self):
if self._transport!=None:
try:
self._transport.disconnect()
- except:
+ except Exception:
self.logger.error("Failed to disconnect from %s", self._host, exc_info=True)
raise
finally:
View
15 haigha/tests/unit/channel_test.py
@@ -245,6 +245,21 @@ def test_process_frames_logs_and_closes_when_dispatch_error_raised(self):
assert_raises( RuntimeError, c.process_frames )
assertEquals( f1, c._frame_buffer[0] )
+
+ def test_process_frames_logs_and_closes_when_systemexit_raised(self):
+ c = Channel(None,None,{})
+ c._connection = mock()
+ c._connection.logger = mock()
+
+ f0 = MethodFrame(20, 30, 40)
+ f1 = MethodFrame('ch_id', 'c_id', 'm_id')
+ c._frame_buffer = deque([ f0, f1 ])
+
+ expect( c.dispatch ).args( f0 ).raises( SystemExit() )
+ stub( c.close )
+
+ assert_raises( SystemExit, c.process_frames )
+ assertEquals( f1, c._frame_buffer[0] )
def test_next_frame_with_a_frame(self):
c = Channel(None,None,{})
View
12 haigha/tests/unit/connection_test.py
@@ -213,6 +213,18 @@ def test_disconnect_when_transport_disconnects_with_error(self):
assert_false( self.connection._connected )
assert_equals( None, self.connection._transport )
+ def test_disconnect_when_systemexit(self):
+ self.connection._connected = 'yup'
+ self.connection._host = 'server'
+
+ expect( self.connection._transport.disconnect ).raises( SystemExit() )
+ stub( self.connection.logger.error )
+ assert_raises( SystemExit, self.connection.disconnect )
+
+ assert_false( self.connection._connected )
+ assert_equals( None, self.connection._transport )
+
+
def test_transport_closed_with_no_args(self):
self.connection._host = 'server'
self.connection._connected = 'yes'
View
18 haigha/tests/unit/writer_test.py
@@ -145,9 +145,9 @@ def test_write_timestamp(self):
def test_write_table(self):
w = Writer()
expect( w._write_item ).args( 'a', 'foo' ).any_order().side_effect(
- lambda: (setattr(w,'_pos',20), w._output_buffer.extend('afoo')) )
+ lambda *args: (setattr(w,'_pos',20), w._output_buffer.extend('afoo')) )
expect( w._write_item ).args( 'b', 'bar' ).any_order().side_effect(
- lambda: (setattr(w,'_pos',20), w._output_buffer.extend('bbar')) )
+ lambda *args: (setattr(w,'_pos',20), w._output_buffer.extend('bbar')) )
assert_true( w is w.write_table({'a':'foo','b':'bar'}) )
assert_equals( '\x00\x00\x00\x08', w._output_buffer[:4] )
@@ -226,7 +226,7 @@ def test_field_timestamp(self):
def test_field_table(self):
w = Writer()
expect( w.write_table ).args( {'foo':'bar'} ).side_effect(
- lambda: w._output_buffer.extend('tdata') )
+ lambda *args: w._output_buffer.extend('tdata') )
w._field_table( {'foo':'bar'} )
assert_equals( 'Ftdata', w._output_buffer )
@@ -245,21 +245,21 @@ def test_field_bytearray(self):
def test_field_iterable(self):
w = Writer()
expect( w._write_field ).args('la').side_effect(
- lambda: w._output_buffer.append('a') )
+ lambda field: w._output_buffer.append('a') )
expect( w._write_field ).args('lb').side_effect(
- lambda: w._output_buffer.append('b') )
+ lambda field: w._output_buffer.append('b') )
w._field_iterable( ['la','lb'] )
expect( w._write_field ).args('ta').side_effect(
- lambda: w._output_buffer.append('a') )
+ lambda field: w._output_buffer.append('a') )
expect( w._write_field ).args('tb').side_effect(
- lambda: w._output_buffer.append('b') )
+ lambda field: w._output_buffer.append('b') )
w._field_iterable( ('ta','tb') )
expect( w._write_field ).args('sa').any_order().side_effect(
- lambda: w._output_buffer.append('s') )
+ lambda field: w._output_buffer.append('s') )
expect( w._write_field ).args('sb').any_order().side_effect(
- lambda: w._output_buffer.append('s') )
+ lambda field: w._output_buffer.append('s') )
w._field_iterable( set(('sa','sb')) )
assert_equals( 'AabAabAss', w._output_buffer )
Please sign in to comment.
Something went wrong with that request. Please try again.