Closed jfurcean closed 3 years ago
@jfurcean Could you clarify why you are except
'ing the RuntimeError: Out of sockets"
? Is this being thrown erroneously by CircuitPython?
The assumption is that it is being thrown correctly, so it triggers a retry on the loop, which in turn causes a call to self._free_sockets()
which would close the "free" sockets. Requests otherwise doesn't automatically close the sockets it uses, it keeps them, only marking them as "free" when no longer in use, and reuses them when you access the same host/port, leading to inevitably running out of sockets.
In 6.2 beta 1 the same code would cause a MemoryError on sock.connect()
in that same loop which in turn would also cause the freeing of sockets. That change to a more specific error message is a consequence of the "Separate SSLSocket from Socket" PR.
In 6.2 beta 1 the same code would cause a MemoryError on sock.connect() in that same loop which in turn would also cause the freeing of sockets. That change to a more specific error message is a consequence of the "Separate SSLSocket from Socket" PR.
I see, thank you for the clarification! I'm going to implement a similar patch within MiniMQTT.
Fixes problem when there are free sockets but are not closed when needed. See #73