Python error prompt: [Errno 24] Analysis and Solution of Too program open files, pythonerrno

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.