Closed
Description
Context manager exit seems to be in place for socket, but:
import time
import wifi
import socketpool
from secrets import secrets
pool = socketpool.SocketPool(wifi.radio)
print("Connect...")
wifi.radio.connect(secrets["ssid"], secrets["password"])
print("RSSI", wifi.radio.ap_info.rssi)
count = 0
packet = bytearray(1)
while True:
count += 1
print(count, end=" ")
packet[0] = 0xFF
with pool.socket(pool.AF_INET, pool.SOCK_DGRAM) as sock:
print("Send...")
sock.sendto(packet, ("192.168.4.32", 16384))
time.sleep(1)
results in:
Adafruit CircuitPython 6.2.0-beta.0 on 2021-01-22; FeatherS2 with ESP32S2
>>> import ntp
Connect...
RSSI -43
1 Send...
2 Send...
3 Send...
4 Send...
5 Send...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ntp.py", line 21, in <module>
File "ntp.py", line 21, in <module>
RuntimeError: Out of sockets
CPython version continues past where my patience wears out:
import time
import socket
pool = socket
count = 0
packet = bytearray(1)
while True:
count += 1
print(count, end=" ")
packet[0] = 0xFF
with pool.socket(pool.AF_INET, pool.SOCK_DGRAM) as sock:
print("Send...")
sock.sendto(packet, ("192.168.4.32", 16384))
time.sleep(1)
6.1.0-rc.1 seems to behave fine.
May be related to adafruit/Adafruit_CircuitPython_Requests#63