OSError: [Errno 24] Too many open files [closed]

asked 2020-01-12 11:57:29 -0500

Zudva gravatar image

updated 2020-01-12 12:05:11 -0500

supra56 gravatar image

I have trouble on my Raspberry pi 4. People counter script crash every too day.

This i have in my lxterminal on user pi:

Traceback (most recent call last): 
  File "people_counter.py", line 146, in <module> 
  File "people_counter.py", line 19, in send_osc 
  File "/home/pi/.virtualenvs/py3cv3/lib/python3.7/site-packages/osc4py3/as_eventloop.py", line 149, in osc_udp_client 
  File "/home/pi/.virtualenvs/py3cv3/lib/python3.7/site-packages/osc4py3/as_eventloop.py", line 230, in _select_monitor 
  File "/home/pi/.virtualenvs/py3cv3/lib/python3.7/site-packages/osc4py3/oscscheduling.py", line 167, in create_platform_socket_monitor 
  File "/home/pi/.virtualenvs/py3cv3/lib/python3.7/site-packages/osc4py3/oscscheduling.py", line 681, in init 
  File "/home/pi/.virtualenvs/py3cv3/lib/python3.7/site-packages/osc4py3/oscscheduling.py", line 612, in init 
  File "/home/pi/.virtualenvs/py3cv3/lib/python3.7/site-packages/osc4py3/oscscheduling.py", line 637, in create_monitor_sockets 
  File "/usr/lib/python3.7/socket.py", line 151, in init 
OSError: [Errno 24] Too many open files

In User limit i have this config:

ulimit -a
ulimit -a выдает такие конфиги:
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 28771
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 500000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 95
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 28771
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by berak
close date 2020-01-12 12:17:06.426155

Comments

Can you post line 151?

supra56 gravatar imagesupra56 ( 2020-01-12 12:07:46 -0500 )edit

File "people_counter.py", line 19, in send_osc

sounds unrelated to opencv

berak gravatar imageberak ( 2020-01-12 12:10:29 -0500 )edit

We need send "id's" to server who listen osc ( udp ) port. We not use OpenCV for sound.

Zudva gravatar imageZudva ( 2020-01-12 12:13:39 -0500 )edit

In 151 to 161 line i have this code:

        trackableObjects[objectID] = to


        send_osc(objectID)
        # draw both the ID of the object and the centroid of the
        # object on the output frame
        text = "ID {}".format(objectID)
        cv2.putText(frame, text, (centroid[0] - 10, centroid[1] - 10),
            cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
        cv2.circle(frame, (centroid[0], centroid[1]), 4, color, -1)
Zudva gravatar imageZudva ( 2020-01-12 12:15:11 -0500 )edit

your opencv code does not use any file handles there, but osc (using sockets) does.

We not use OpenCV for sound.

opencv does not deal with audio at all.

let me close this.

please debug your osc code for leaks, and raise an issue with the appropriate maintainer, thank you.

berak gravatar imageberak ( 2020-01-12 12:16:48 -0500 )edit

Ok! I write osc4py3 module developer.

Zudva gravatar imageZudva ( 2020-01-12 15:20:37 -0500 )edit

That is not an error in line 19. We are looking at line 151...Too many open files. I was looking at config that you re stating that open files (-n) 500000. You set to 4096 or higher. I used to set between 4096 to 65355 for tcp. If this doen't work your limit. Then reduce to 128.

supra56 gravatar imagesupra56 ( 2020-01-13 04:49:50 -0500 )edit

This what I have on Raspberry pi 3/3b/4:

#ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 256
pipe size            (512 bytes, -p) 1
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes
supra56 gravatar imagesupra56 ( 2020-01-13 04:52:24 -0500 )edit