1012 def readReady(self, stream): |
1012 def readReady(self, stream): |
1013 """ |
1013 """ |
1014 Public method called when there is data ready to be read. |
1014 Public method called when there is data ready to be read. |
1015 |
1015 |
1016 @param stream file like object that has data to be written |
1016 @param stream file like object that has data to be written |
1017 """ |
1017 @return flag indicating an error condition |
|
1018 @rtype bool |
|
1019 """ |
|
1020 error = False |
|
1021 |
|
1022 self.lockClient() |
1018 try: |
1023 try: |
1019 self.lockClient() |
|
1020 command = stream.readCommand() |
1024 command = stream.readCommand() |
1021 self.unlockClient() |
|
1022 except Exception: |
1025 except Exception: |
1023 return |
1026 error = True |
1024 |
1027 self.unlockClient() |
1025 if len(command) == 0: |
1028 |
|
1029 if len(command) == 0 or error: |
1026 self.sessionClose() |
1030 self.sessionClose() |
1027 return |
1031 else: |
1028 |
1032 self.handleJsonCommand(command) |
1029 self.handleJsonCommand(command) |
1033 |
|
1034 return error |
1030 |
1035 |
1031 def writeReady(self, stream): |
1036 def writeReady(self, stream): |
1032 """ |
1037 """ |
1033 Public method called when we are ready to write data. |
1038 Public method called when we are ready to write data. |
1034 |
1039 |
1077 except (select.error, KeyboardInterrupt, socket.error): |
1082 except (select.error, KeyboardInterrupt, socket.error): |
1078 # just carry on |
1083 # just carry on |
1079 continue |
1084 continue |
1080 |
1085 |
1081 if self.readstream in rrdy: |
1086 if self.readstream in rrdy: |
1082 self.readReady(self.readstream) |
1087 error = self.readReady(self.readstream) |
|
1088 if error: |
|
1089 break |
1083 |
1090 |
1084 if self.writestream in wrdy: |
1091 if self.writestream in wrdy: |
1085 self.writeReady(self.writestream) |
1092 self.writeReady(self.writestream) |
1086 |
1093 |
1087 if self.errorstream in wrdy: |
1094 if self.errorstream in wrdy: |