diff --git a/README.md b/README.md index 05bbb3d..9262312 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ CREATE TABLE image_hashes ( ``` 查询脚本:查询两个qq号之间不连续的地址,找出漏上传的QQ号 ```mysql +USE qqinfo; SELECT t1.id, t1.next_id FROM ( SELECT id, LEAD(id) OVER (ORDER BY id) AS next_id diff --git a/Thread.py b/Thread.py index fc54093..7507705 100644 --- a/Thread.py +++ b/Thread.py @@ -1,8 +1,5 @@ import pymysql, threading, time from queue import Queue - -import requests - from concurrent.futures import ThreadPoolExecutor from Tools import config, Hash, Image, imagehash, os, logging, download_image, remove_image, clean_image, compare @@ -27,7 +24,7 @@ class MySQLConnectionPool: ) self.pool.put(conn) - def get_connection(self, max_retries=5, wait_time=1): + def get_connection(self, max_retries=65535, wait_time=3): """获取一个数据库连接,如果连接池为空,继续尝试直到能够获取连接""" retries = 0 while retries < max_retries: diff --git a/Tools.py b/Tools.py index 4cd44af..654623b 100644 --- a/Tools.py +++ b/Tools.py @@ -119,7 +119,7 @@ def download_image(_qqnumber): # 创建一个会进行重试的适配器 session = requests.Session() retry = Retry( - total=5, # 最多重试3次 + total=255, # 最多重试255次 backoff_factor=1, # 每次重试的等待时间增加 status_forcelist=[500, 502, 503, 504], # 针对这些HTTP状态码才重试 ) diff --git a/config.cfg b/config.cfg index e2589f7..562657d 100644 --- a/config.cfg +++ b/config.cfg @@ -11,7 +11,7 @@ database = qqinfo table_name = image_hashes id_column_name = id hash_column_name = hash -pool_size = 100 +pool_size = 2000 [logging] level = 20 diff --git a/main.py b/main.py index 8b36c9f..f92e226 100644 --- a/main.py +++ b/main.py @@ -1,30 +1,32 @@ -from time import sleep from Thread import UploadThread, FindThread, ByNetFindThread, MySQLConnectionPool from Tools import imagehash, Image, os, config -type = int(config['settings']['type']) -TargetRange = list(map(int, config['settings']['TargetRange'].split(','))) -TargetImagePath = config['settings']['TargetImage'] -TargetImage = Image.open(TargetImagePath) -TargetImageHash = bytes.fromhex(str(imagehash.average_hash(TargetImage))) -baseArr = TargetRange[0] -if not os.path.exists('img'): - os.makedirs('img') - if __name__ == '__main__': - if type == 1: + mytype = int(config['settings']['type']) + TargetRange = list(map(int, config['settings']['TargetRange'].split(','))) + baseArr = TargetRange[0] + if not os.path.exists('img'): + os.makedirs('img') + + if mytype == 1: + TargetImagePath = config['settings']['TargetImage'] + TargetImage = Image.open(TargetImagePath) + TargetImageHash = bytes.fromhex(str(imagehash.average_hash(TargetImage))) pool = MySQLConnectionPool() Thread = FindThread(TargetImageHash, pool) Thread.start() - elif type == 2: + elif mytype == 2: + TargetImagePath = config['settings']['TargetImage'] + TargetImage = Image.open(TargetImagePath) + TargetImageHash = bytes.fromhex(str(imagehash.average_hash(TargetImage))) while baseArr <= TargetRange[1]: Thread = ByNetFindThread(TargetImageHash, baseArr) Thread.start() baseArr += 1 - elif type == 3: + elif mytype == 3: pool = MySQLConnectionPool() while baseArr <= TargetRange[1]: Thread = UploadThread(baseArr, pool)