165 data += newData |
165 data += newData |
166 except OSError as err: |
166 except OSError as err: |
167 if err.errno != 11: |
167 if err.errno != 11: |
168 data = None # in case some data was received already |
168 data = None # in case some data was received already |
169 break |
169 break |
|
170 except MemoryError: |
|
171 data = None # in case some data was received already |
|
172 break |
170 return data |
173 return data |
171 |
174 |
172 def receiveJsonCommand(self, sock): |
175 def receiveJsonCommand(self, sock): |
173 """ |
176 """ |
174 Public method to receive a JSON encoded command and data. |
177 Public method to receive a JSON encoded command and data. |
326 connection, address = sock.accept() # Should be ready to read |
329 connection, address = sock.accept() # Should be ready to read |
327 if self.__connection is None: |
330 if self.__connection is None: |
328 print(f"'eric-ide' connection from {address[0]}, port {address[1]}") |
331 print(f"'eric-ide' connection from {address[0]}, port {address[1]}") |
329 # noqa: M801 |
332 # noqa: M801 |
330 self.__connection = connection |
333 self.__connection = connection |
|
334 self.__connection.settimeout(10) |
331 data = types.SimpleNamespace( |
335 data = types.SimpleNamespace( |
332 name="eric-ide", address=address, handler=self.__serviceIdeConnection |
336 name="eric-ide", address=address, handler=self.__serviceIdeConnection |
333 ) |
337 ) |
334 events = selectors.EVENT_READ |
338 events = selectors.EVENT_READ |
335 self.__selector.register(self.__connection, events, data=data) |
339 self.__selector.register(self.__connection, events, data=data) |