Python在未完成脚本的情况下退出

2024-05-06 10:08:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在获取线程“MainThread”(0x1)已退出,代码为0(0x0)。在脚本完全结束之前。一段时间后,我的脚本中有一些额外的部分num<;maxthreads循环,但解释器似乎在满足此条件后立即退出。我想在这之后继续,我做错了什么

def creator():
    s = requests.session()
    email = randomName()
    password = randomPassword()
    name = names.get_full_name()

    data={
    "displayname":name,
    "creation_point":"https://login.app.igloo.com?utm_source",
    "birth_month":monthnumber,
    "email":email + "@gmail.com",
    "password":password,
    }

try:

    r = s.post("https://spclient.wg.igloo.com/signup/public/v1/account/",data=data,proxies=proxy1.FormatProxy())
    if '{"status":1,"' in r.text:
        open("creatediglooaccountsgen.txt", "a+").write(email + "@gmail.com:" + password + ":" + PROXY + "\n")
        created += 1
    else:
        errors += 1
except:
    pass
    print("DONE")
maxi = 4
maxthreads = 4
num = 0

while num < maxthreads:
    num += 1
    threading.Thread(target=creator).start()  # Start Checking Thread
chrome = webdriver.chrome(options=chrome_options)
driver.get("https://igloo.com/en/login")
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC



#from selenium findElement
with open('creatediglooaccountsgen.txt') as f:
    credentials = [x.strip().split(':', 1) for x in f]
for username, password in credentials:
@type='text']")
@type='text'").send_keys(username)
    driver.find_element_by_id("login-username").send_keys(username)
    driver.find_element_by_id("login-password").send_keys(password)
try:
    time.sleep(10)
    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Log In']"))).click()
except:
    print('exception occured')
time.sleep(3)

driver.close()

我试图尽可能多地删减以压缩它,但实际上脚本在while num < maxthreads行之后停止(在指定的4个循环之后,因为maxi设置为4),但我希望它在这之后继续

任何想法, 谢谢