[Zodb-checkins] CVS: ZODB3/ZEO/zrpc - smac.py:1.30
Guido van Rossum
guido@python.org
Sat, 28 Sep 2002 22:46:59 -0400
Update of /cvs-repository/ZODB3/ZEO/zrpc
In directory cvs.zope.org:/tmp/cvs-serv23703
Modified Files:
smac.py
Log Message:
Change state to a proper Boolean (0/1) instead of one of those weird
None/1 thingies. Also explain how state and msg_size interact.
=== ZODB3/ZEO/zrpc/smac.py 1.29 => 1.30 ===
--- ZODB3/ZEO/zrpc/smac.py:1.29 Fri Sep 27 15:28:29 2002
+++ ZODB3/ZEO/zrpc/smac.py Sat Sep 28 22:46:58 2002
@@ -63,9 +63,16 @@
self._debug = debug
elif not hasattr(self, '_debug'):
self._debug = __debug__
- self.__state = None
self.__inp = None # None, a single String, or a list
self.__input_len = 0
+ # Instance variables __state and __msg_size work together:
+ # when __state == 0:
+ # __msg_size == 4, and the next thing read is a message size;
+ # when __state == 1:
+ # __msg_size is variable, and the next thing read is a message.
+ # The next thing read is always of length __msg_size.
+ # The state alternates between 0 and 1.
+ self.__state = 0
self.__msg_size = 4
self.__output = []
self.__closed = 0
@@ -116,13 +123,13 @@
while (offset + msg_size) <= input_len:
msg = inp[offset:offset + msg_size]
offset = offset + msg_size
- if state is None:
+ if not state:
# waiting for message
msg_size = struct.unpack(">i", msg)[0]
state = 1
else:
msg_size = 4
- state = None
+ state = 0
self.message_input(msg)
self.__state = state