Open justmobilize opened 2 months ago
I will note, that this is specific to the new feature in 9.1.0
that allows SSL to be used with the WIZnet5k
note, for those who wondered: that particular URL redirects to https:, so this is using https even though the url is http
@jepler the same thing happens if it starts as https:
. Should I update the example?
My assumption (although probably totally wrong) is that some resource is still being held onto by python when the fake sleep happens
and verified. This doesn't crash:
import alarm
import board
import busio
import digitalio
import time
import adafruit_connection_manager
import adafruit_requests
from adafruit_wiznet5k import adafruit_wiznet5k
# delay so you can connect
print("starting:", end="")
for i in range(10):
print(".", end="")
time.sleep(1)
print()
print("getting radio")
chip_select = digitalio.DigitalInOut(board.D10)
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
radio = adafruit_wiznet5k.WIZNET5K(spi, chip_select, is_dhcp=True)
print("getting pool, ssl, requets")
pool = adafruit_connection_manager.get_radio_socketpool(radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(radio)
requests = adafruit_requests.Session(pool, ssl_context)
print("getting quotes")
test_url = "http://www.adafruit.com/api/quotes.php"
with requests.get(test_url) as response:
result = response.text
print(result)
adafruit_connection_manager.connection_manager_close_all(release_references=True)
print("sleeping")
time_alarm = alarm.time.TimeAlarm(monotonic_time=time.monotonic() + 5)
alarm.exit_and_deep_sleep_until_alarms(time_alarm)
what if your code doesn't deep sleep, but just exits?
That works fine. So does supervisor.reload()
I was wrong, still had the old code. It fails the same way with both.
Being even more specific, this fixes it:
#connection_manager_close_all()
connection_manager = adafruit_connection_manager._global_connection_managers.get(pool)
connection_manager._free_sockets(force=True)
So it's the open socket via the ssl_context
CircuitPython version
Code/REPL
Behavior
Description
No response
Additional information
No response