【发布时间】:2018-07-16 15:18:16
【问题描述】:
我在树莓派 3 的 while 循环中调用广播和接收数据函数。在while循环之后,我想调用另一个函数,它将帧发送到他的邻居节点,但是当这个函数(send_req_status_frame())调用时,它给出了一个错误
Traceback (most recent call last):
File "Neighbortest.py", line 347, in <module>
File "Neighbortest.py", line 286, in send_req_status_frame
File "/usr/lib/python3.5/socket.py", line 134, in __init__
OSError: [Errno 24] Too many open files
“send_req-status-frame”函数的“s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)”行报错。 谁能帮我解决这个错误?
def send_req_status_frame():
message='req_status'
previous_ip=My_ip
sender_ip=My_ip
T_message= message + ";" + previous_ip + ";" + sender_ip
T_message_bytes= bytes(T_message,'utf-8')
print ("----Send_req_status_frame: Send to My_Neighborlist",MyNeighborSet_ip)
PORT = 12345
print ("just after socket")
for i in range (len(MyNeighborSet_ip)):
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)
s.connect((MyNeighborSet_ip[i],PORT))
s.sendall (T_message_bytes) #here is issue of 'byte'
s.close()
start_time=time.time() temp = concurrent.futures.ThreadPoolExecutor (max_workers=2)
while(((time.time()-start_time)<NeighborDiscovery_Time_Interval) and (len(MyNeighborSet_ip) <= Nmax_Per_hop)):
if (time.time()-start_time<hello_Broadcast_Period):
broadcast_hello()
try:
temp.submit(received_hello)
except:
print("###################")
send_req_status_frame()
【问题讨论】:
标签: python python-3.x sockets raspberry-pi3 serversocket