128 |
128 |
129 # Give time to process latest response on server side |
129 # Give time to process latest response on server side |
130 time.sleep(0.5) |
130 time.sleep(0.5) |
131 self.__connection.shutdown(socket.SHUT_RDWR) |
131 self.__connection.shutdown(socket.SHUT_RDWR) |
132 self.__connection.close() |
132 self.__connection.close() |
|
133 |
|
134 def poll(self): |
|
135 """ |
|
136 Public method to check and receive one message (if available) |
|
137 """ |
|
138 try: |
|
139 rrdy, wrdy, xrdy = select.select([self.__connection], [], [], 0) |
|
140 if self.__connection in rrdy: |
|
141 self.__receiveJson() |
|
142 |
|
143 except (select.error, KeyboardInterrupt, socket.error): |
|
144 # just ignore these |
|
145 return |
|
146 |
|
147 except Exception: |
|
148 exctype, excval, exctb = sys.exc_info() |
|
149 tbinfofile = io.StringIO() |
|
150 traceback.print_tb(exctb, None, tbinfofile) |
|
151 tbinfofile.seek(0) |
|
152 tbinfo = tbinfofile.read() |
|
153 del exctb |
|
154 self.sendJson("ClientException", { |
|
155 "ExceptionType": str(exctype), |
|
156 "ExceptionValue": str(excval), |
|
157 "Traceback": tbinfo, |
|
158 }) |