Python error hint: [Errno] Too many open files analysis and resolution

Source: Internet
Author: User

Background

Recently found an error in the work, the following error occurs frequently when executing a multithreaded 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] Too many open files ',))

More bizarre ...

Analysis

Bo master himself in some small projects often need to carry out multi-threaded batch scanning to collect data, such as the ability to collect data, of course, the more threads the better, so I usually use 3,000 threads to scan, in determining the bandwidth is sufficient, the system hardware configuration is high enough to continue the problem, This reminds me of the limitations of the system.

Through the search engine I found a description of the system limitations, execution

$ ulimit-n1024

The result is 1024, and the system is limited to opening 1024 files at the same time, which is obviously too little.

Solve

The solution to this problem is simple, modify the following file directly

sudo vim/etc/security/limits.conf

The last two lines of code to add to this file

* Soft nofile 10240* hard Nofile 10240

Of course, this number according to their own needs to make changes can be saved after logging off and re-login just fine.

Python error hint: [Errno] Too many open files analysis and resolution

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.