Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

大量请求代理的话,要卡死 #1373

Open
amobaishi opened this issue Feb 20, 2025 · 1 comment
Open

大量请求代理的话,要卡死 #1373

amobaishi opened this issue Feb 20, 2025 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@amobaishi
Copy link

不是Ui卡来不动,而是不能代理了,一个包都代理不了,要强制退出后,再打开才能代理。macos arm版

@amobaishi amobaishi added the question Further information is requested label Feb 20, 2025
@amobaishi
Copy link
Author

用了几天,真的很6,就是要卡死不知道为什么,写了段测试代码,发现主要是https的请求要卡住,麻烦看看。

import requests
import time
from concurrent.futures import ThreadPoolExecutor
import urllib3
from multiprocessing import Process, Lock, Value

urllib3.disable_warnings()

def test(lock, Counter):
    while 1:
        proxies = {
            "http": "http://127.0.0.1:9000",
            "https": "http://127.0.0.1:9000",
        }
        url = 'https://www.xxxxxx.com/'
        # url = 'http://127.0.0.1:8000'
        try:
            requests.get(url, proxies=proxies, verify=False)
        except:
            pass
        with lock:
            Counter.value += 1
        print(time.asctime(time.localtime(time.time())), Counter.value)

def fun1(lock, Counter):
    with ThreadPoolExecutor(max_workers=100) as t: 
        t.submit(test, lock, Counter)

if __name__ == '__main__':
    process_list = []
    lock = Lock()
    Counter = Value('i', 0)
    for i in range(50):  
        p = Process(target=fun1, args=(lock, Counter)) 
        p.start()
        process_list.append(p)

    for i in process_list:
        p.join()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants