Python error prompt: [Errno 24] Analysis and Solution of Too program open files, pythonerrno
Background
I recently found an error in my work. The following error occurs frequently when I execute a multi-thread scan script.
HTTPConnectionPool(host=‘t.tips', port=80): Max retries exceeded with url: /index.php (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x7f29d4081150>: Failed to establish a new connection: [Errno 24] Too many open files',))
Weird...
Analysis
Some small projects in the hands of bloggers often require multi-thread batch scanning to collect data. The more threads, the better the function like data collection, therefore, I usually use 3000 threads for scanning. If the bandwidth is sufficient and the system hardware configuration is high enough, the above problems still occur, this reminds me whether it is caused by system restrictions.
Using the search engine, I found an introduction to System Restrictions and executed
$ ulimit -n1024
The result is 1024. The system limit is to open 1024 files at the same time, which is obviously too small.
Solution
The solution to this problem is simple. Modify the following file directly.
sudo vim /etc/security/limits.conf
Add the last two lines of code to this file
* soft nofile 10240* hard nofile 10240
Of course, you can modify this number as needed. Just save it and log out and log on again.
Summary
The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.