|
@@ -727,30 +727,31 @@ def run_threading_login(account, password, url, single_proxy):
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_threading_order(max_threads, account_path, url):
|
|
def run_threading_order(max_threads, account_path, url):
|
|
|
- try:
|
|
|
|
|
- with open('accounts.txt', 'r') as accounts:
|
|
|
|
|
- account_list = accounts.readlines()
|
|
|
|
|
|
|
+ while True:
|
|
|
|
|
+ try:
|
|
|
|
|
+ with open('accounts.txt', 'r') as accounts:
|
|
|
|
|
+ account_list = accounts.readlines()
|
|
|
|
|
|
|
|
- threads = []
|
|
|
|
|
- for account in account_list:
|
|
|
|
|
- single_proxy, random_index = get_random_proxy_at_redis(100)
|
|
|
|
|
- thread = threading.Thread(target=get_ticket_order,
|
|
|
|
|
- args=(account, "panyue666", url, single_proxy))
|
|
|
|
|
- threads.append(thread)
|
|
|
|
|
- thread.start()
|
|
|
|
|
|
|
+ threads = []
|
|
|
|
|
+ for account in account_list:
|
|
|
|
|
+ single_proxy, random_index = get_random_proxy_at_redis(100)
|
|
|
|
|
+ thread = threading.Thread(target=get_ticket_order,
|
|
|
|
|
+ args=(account, "panyue666", url, single_proxy))
|
|
|
|
|
+ threads.append(thread)
|
|
|
|
|
+ thread.start()
|
|
|
|
|
|
|
|
- # 如果当前线程数达到上限,等待有线程结束后再创建新线程
|
|
|
|
|
- if len(threads) == max_threads:
|
|
|
|
|
- for t in threads:
|
|
|
|
|
- t.join()
|
|
|
|
|
- threads.clear()
|
|
|
|
|
|
|
+ # 如果当前线程数达到上限,等待有线程结束后再创建新线程
|
|
|
|
|
+ if len(threads) == max_threads:
|
|
|
|
|
+ for t in threads:
|
|
|
|
|
+ t.join()
|
|
|
|
|
+ threads.clear()
|
|
|
|
|
|
|
|
- # 等待所有线程执行完毕
|
|
|
|
|
- for thread in threads:
|
|
|
|
|
- thread.join()
|
|
|
|
|
|
|
+ # 等待所有线程执行完毕
|
|
|
|
|
+ for thread in threads:
|
|
|
|
|
+ thread.join()
|
|
|
|
|
|
|
|
- except Exception as ex:
|
|
|
|
|
- loggerKit.error(f'error: {traceback.format_exc()}, account:{account_path}')
|
|
|
|
|
|
|
+ except Exception as ex:
|
|
|
|
|
+ loggerKit.error(f'error: {traceback.format_exc()}, account:{account_path}')
|
|
|
|
|
|
|
|
|
|
|
|
|
def run_daily_job(hour, minute):
|
|
def run_daily_job(hour, minute):
|
|
@@ -776,7 +777,7 @@ def run_daily_job(hour, minute):
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
-def run_manual_job(hour, minute, pocket_url):
|
|
|
|
|
|
|
+def run_manual_job(hour, minute, thread_num, pocket_url):
|
|
|
global event
|
|
global event
|
|
|
# 获取当前日期和时间
|
|
# 获取当前日期和时间
|
|
|
now = datetime.datetime.now()
|
|
now = datetime.datetime.now()
|
|
@@ -788,7 +789,7 @@ def run_manual_job(hour, minute, pocket_url):
|
|
|
# 计算等待时间
|
|
# 计算等待时间
|
|
|
wait_time = (run_time - now).total_seconds()
|
|
wait_time = (run_time - now).total_seconds()
|
|
|
# 添加定时任务,并保存事件对象
|
|
# 添加定时任务,并保存事件对象
|
|
|
- event = scheduler.enter(wait_time, 1, manual_job, argument=(pocket_url,))
|
|
|
|
|
|
|
+ event = scheduler.enter(wait_time, 1, manual_job, argument=(thread_num, pocket_url,))
|
|
|
# 启动定时器
|
|
# 启动定时器
|
|
|
scheduler.run()
|
|
scheduler.run()
|
|
|
|
|
|
|
@@ -821,9 +822,8 @@ def looper_job():
|
|
|
"""
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
-def manual_job(pocket_url):
|
|
|
|
|
- while 1:
|
|
|
|
|
- process_running_manual(max_threads=1, pocket_url=pocket_url)
|
|
|
|
|
|
|
+def manual_job(thread_num, pocket_url):
|
|
|
|
|
+ process_running_manual(max_threads=thread_num, pocket_url=pocket_url)
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|