Hi,
I have a similar problem. I would like to add proper exception handling to a non blocking socket write (and read) access:
Code: Select all
def _sock_timeout(self, poller, socket_timeout):
# omitting some details here...
if self.sock:
res = poller.poll([...])
def _write(self, bytes_wr, length=-1):
# omitting some details here...
# check exception here:
self._sock_timeout(self.poller_w, self.socket_timeout)
# and check exception here:
out = self.sock.write(bytes_wr, length)
I added some exception handling around
_sock_timeout() and
sock.write() above and found that (during my short testing period) the former never threw any exception, but
sock.write() sometimes threw an exception with error codes -128 or -113.
Why do I get negative error codes? Decoding the error as suggested in
https://docs.micropython.org/en/latest/ ... .errorcode -
uerrno.errorcode[uerrno.exc] fails due to the negative array index. Following the cross references to CPython's errno did not help me any further.
The explanations in
https://docs.micropython.org/en/latest/ ... ml#methods did not answer my questions, either.
Where can I look up all supported error codes (of a given MicroPython port) or - even better - all possible exceptions of any library call?
Thanks for any hints!
Cheers, Matthias
P.S.: Those exceptions don't seem to be critical - if I simply ignore them, the code works as expected.