Upgrade amqp vendored library to 1.4.5

This commit is contained in:
Matthew Jones
2014-08-06 13:55:08 -04:00
parent efed138e8b
commit 6f6f8675f9
4 changed files with 73 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
Local versions of third-party packages required by Tower. Package names and Local versions of third-party packages required by Tower. Package names and
versions are listed below, along with notes on which files are included. versions are listed below, along with notes on which files are included.
amqp==1.4.4 (amqp/*) amqp==1.4.5 (amqp/*)
ansi2html==1.0.6 (ansi2html/*) ansi2html==1.0.6 (ansi2html/*)
anyjson==0.3.3 (anyjson/*) anyjson==0.3.3 (anyjson/*)
argparse==1.2.1 (argparse.py, needed for Python 2.6 support) argparse==1.2.1 (argparse.py, needed for Python 2.6 support)

View File

@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
from __future__ import absolute_import from __future__ import absolute_import
VERSION = (1, 4, 4) VERSION = (1, 4, 5)
__version__ = '.'.join(map(str, VERSION[0:3])) + ''.join(VERSION[3:]) __version__ = '.'.join(map(str, VERSION[0:3])) + ''.join(VERSION[3:])
__author__ = 'Barry Pederson' __author__ = 'Barry Pederson'
__maintainer__ = 'Ask Solem' __maintainer__ = 'Ask Solem'

View File

@@ -144,25 +144,62 @@ class AMQPReader(object):
def read_item(self): def read_item(self):
ftype = ord(self.input.read(1)) ftype = ord(self.input.read(1))
if ftype == 83: # 'S'
# 'S': long string
if ftype == 83:
val = self.read_longstr() val = self.read_longstr()
elif ftype == 73: # 'I' # 's': short string
val = unpack('>i', self.input.read(4))[0] elif ftype == 115:
elif ftype == 68: # 'D' val = self.read_shortstr()
d = self.read_octet() # 'b': short-short int
n = unpack('>i', self.input.read(4))[0] elif ftype == 98:
val = Decimal(n) / Decimal(10 ** d) val, = unpack('>B', self.input.read(1))
elif ftype == 84: # 'T' # 'B': short-short unsigned int
val = self.read_timestamp() elif ftype == 66:
elif ftype == 70: # 'F' val, = unpack('>b', self.input.read(1))
val = self.read_table() # recurse # 'U': short int
elif ftype == 65: # 'A' elif ftype == 85:
val = self.read_array() val, = unpack('>h', self.input.read(2))
elif ftype == 116: # 'u': short unsigned int
val = self.read_bit() elif ftype == 117:
val, = unpack('>H', self.input.read(2))
# 'I': long int
elif ftype == 73:
val, = unpack('>i', self.input.read(4))
# 'i': long unsigned int
elif ftype == 105: # 'l'
val, = unpack('>I', self.input.read(4))
# 'L': long long int
elif ftype == 76:
val, = unpack('>q', self.input.read(8))
# 'l': long long unsigned int
elif ftype == 108:
val, = unpack('>Q', self.input.read(8))
# 'f': float
elif ftype == 102:
val, = unpack('>f', self.input.read(4))
# 'd': double
elif ftype == 100: elif ftype == 100:
val = self.read_float() val = self.read_float()
elif ftype == 86: # 'V' # 'D': decimal
elif ftype == 68:
d = self.read_octet()
n, = unpack('>i', self.input.read(4))
val = Decimal(n) / Decimal(10 ** d)
# 'F': table
elif ftype == 70:
val = self.read_table() # recurse
# 'A': array
elif ftype == 65:
val = self.read_array()
# 't' (bool)
elif ftype == 116:
val = self.read_bit()
# 'T': timestamp
elif ftype == 84:
val = self.read_timestamp()
# 'V': void
elif ftype == 86:
val = None val = None
else: else:
raise FrameSyntaxError( raise FrameSyntaxError(

View File

@@ -109,9 +109,13 @@ class _AbstractTransport(object):
def __del__(self): def __del__(self):
try: try:
self.close() # socket module may have been collected by gc
except socket.error: # if this is called by a thread at shutdown.
pass if socket is not None:
try:
self.close()
except socket.error:
pass
finally: finally:
self.sock = None self.sock = None
@@ -235,12 +239,17 @@ class SSLTransport(_AbstractTransport):
def _write(self, s): def _write(self, s):
"""Write a string out to the SSL socket fully.""" """Write a string out to the SSL socket fully."""
write = self.sock.write try:
while s: write = self.sock.write
n = write(s) except AttributeError:
if not n: # Works around a bug in python socket library
raise IOError('Socket closed') raise IOError('Socket closed')
s = s[n:] else:
while s:
n = write(s)
if not n:
raise IOError('Socket closed')
s = s[n:]
class TCPTransport(_AbstractTransport): class TCPTransport(_AbstractTransport):