Permalink
Browse files

read and parse incomming packets untill valid ASN.1 received

  • Loading branch information...
1 parent 6003bf0 commit 3ef456ebc65d9cc891b1fc90c50f070594a6f55c Stanislav Yudin committed Jun 29, 2011
Showing with 18 additions and 8 deletions.
  1. +10 −1 debian/changelog
  2. +7 −6 proto/__init__.py
  3. +1 −1 setup.py
View
@@ -1,7 +1,16 @@
-python-proto (0.4.1.1cyclozzo1) lucid; urgency=high
+python-proto (0.4.2.1cyclozzo1) lucid; urgency=low
+ * Decode read request data until the whole valid ASN.1 payload received
+
+ -- Cyclozzo Builder <cyclozzo@repo> Wed, 29 Jun 2011 17:21:53 +0530
+
+python-proto (0.4.1.1cyclozzo2) lucid; urgency=low
+
+ [ Stanislav Yudin ]
* Try to parse response data with available response_class each time to figure out the real end of received response.
* Prevents response reading errors on slow networks
+
+ -- Cyclozzo Builder <cyclozzo@repo> Thu, 02 Jun 2011 15:48:57 +0530
python-proto (0.4.0.1cyclozzo1) lucid; urgency=low
View
@@ -135,9 +135,8 @@ def handle_socket(*args, **kw):
"""
Reading packets
"""
- data = socket.recv_data(None)
#call method
- service_name, method_name, request_inst, response_class = packet.decode_request(data, get_pb2_module())
+ service_name, method_name, request_inst, response_class = socket.recv_data(None)
log.info('rpc api %s.%s started' % (type(server).__name__, method_name))
log.debug('rpc service object: %s (%s)' % (service_name, getattr(get_pb2_module(), service_name)))
if not isinstance(server, getattr(get_pb2_module(), service_name) ):
@@ -196,7 +195,7 @@ def recv_data(self, response_type):
while True:
data = None
try:
- data = self.__socket.recv(4096)#, socket.MSG_DONTWAIT)
+ data = self.__socket.recv(SIZE)
if not data:
log.debug('no more data in socket')
@@ -210,16 +209,18 @@ def recv_data(self, response_type):
log.debug('whole data packet was received.')
return decoded_packet
except Exception, ex:
- log.debug('waiting for the whole packet.')
continue
except socket.error, err:
#EAGAIN & EWOULDBLOCK
if err.errno != 11:
raise err
elif total_data and not response_type:
- log.debug('looks like the whole data received.')
- break
+ try:
+ service_name, method_name, request_inst, response_class = packet.decode_request(total_data, get_pb2_module())
+ return service_name, method_name, request_inst, response_class
+ except Exception, ex:
+ continue
if not total_data:
log.debug('socket disconnected!')
View
@@ -7,7 +7,7 @@
setup(
name='proto',
- version='0.4.1',
+ version='0.4.2',
description="The \"Proto!\" Python Async RPC based on ProtocolBuffers and TCP sockets.",
author="Stanislav Yudin",
author_email="decvar@gmail.com",

0 comments on commit 3ef456e

Please sign in to comment.