micropython error trail confusing me
Have you read that David Sedaris book 'Me talk pretty one day', there is a story in there about his troubles learning a new language, reminds me of my struggles with micropython, it certainly ain't pretty.
Here is the block of code from urequests
434 def close(self): 435 if self.raw: self.raw.close(); self.raw = None 436 self._cached = None 437 @property 438 def content(self): 439 if self._cached is None: 440 try: self._cached = self.raw.read() 441 finally: self.raw.close(); self.raw = None 442 return self._cached
and these are the errors
03/03 23:59:56 line 440 OSError: [Errno -76] MBEDTLS_ERR_NET_RECV_FAILED
03/03 23:59:56 line 441 AttributeError: NoneType object has no attribute close
I understand the first error. If there is no self.raw then you can't read it. But the second error confuses me self.raw.close presumably calls the close fn @ line 434. The first thing it does is check if self.raw exists before it tries to close it. So how come the attribute error?
while I see that good timeout-functionality is very important to everyone out there (and probably for us as well), we haven't had the chance to care about these details yet. However, we will be happy to get any support for that ;].
With kind regards,
@andreas Interesting Andreas, I'll have a play with that.
Has your team thought about applying their talents to the problem of socket timeout after the DNS lookup in micropython? I did some experimenting after Peter's post in https://forum.pycom.io/topic/5547/power-saving-mode-psm-in-nb-iot-problems-with-reconnecting-after-deepsleep/2 In particular I played with his commented out lines where he had tried socket timeout, a topic dear to my heart.
- short timeouts (0.1s) work & throw a TimeoutError as an exception. Although, interestingly, you can't capture it with an 'except TimeoutError'
- longer timeouts (5s) don't work and micropython will wait longer than the socket timeout for a server response.
we took the chance to improve the
urequestsmodule according to your observations . It has also been updated to be compatible with CPython.
With kind regards,
The two lines  of the
urequestsshould probably be replaced with just
@andreas So whoever wrote urequests has the 'if self.raw' test in the wrong place? I need to check it before I call self.raw.close not inside the close() function?
So how come the attribute error?
line 441 AttributeError: NoneType object has no attribute close