120 def run(self): |
120 def run(self): |
121 """ |
121 """ |
122 Public method implementing the main loop of the client. |
122 Public method implementing the main loop of the client. |
123 """ |
123 """ |
124 try: |
124 try: |
|
125 selectErrors = 0 |
125 while True: |
126 while True: |
126 try: |
127 try: |
127 rrdy, wrdy, xrdy = select.select( |
128 rrdy, wrdy, xrdy = select.select( |
128 [self.__connection], [], []) |
129 [self.__connection], [], []) |
129 except (select.error, KeyboardInterrupt, socket.error): |
130 except (select.error, KeyboardInterrupt, socket.error): |
130 # just carry on |
131 selectErrors += 1 |
131 continue |
132 if selectErrors <= 10: # selected arbitrarily |
|
133 # just carry on |
|
134 continue |
|
135 else: |
|
136 break |
|
137 |
|
138 # reset select errors |
|
139 selectErrors = 0 |
132 |
140 |
133 if self.__connection in rrdy: |
141 if self.__connection in rrdy: |
134 method, params = self.__receiveJson() |
142 method, params = self.__receiveJson() |
135 if method is not None: |
143 if method is not None: |
136 if method == "Exit": |
144 if method == "Exit": |