Commit 2cd4ba0c by lei

1

parent 7cd7c24b
...@@ -12,9 +12,10 @@ import multiprocessing ...@@ -12,9 +12,10 @@ import multiprocessing
class DownLoad: class DownLoad:
def __init__(self, lock): def __init__(self, lock, thisid):
self.key = 'laravel_database_discord_img_download' self.key = 'laravel_database_discord_img_download'
self.lock = lock self.lock = lock
self.thisid = thisid
self.header = { self.header = {
'Accept': 'application/json', 'Accept': 'application/json',
'Content-Type': 'application/json', 'Content-Type': 'application/json',
...@@ -96,12 +97,12 @@ class DownLoad: ...@@ -96,12 +97,12 @@ class DownLoad:
await self.task_callback(False, '', task, '转存discord图片失败') await self.task_callback(False, '', task, '转存discord图片失败')
else: else:
time.sleep(3) time.sleep(3)
logger.info('不存在任务,等待3秒') logger.info(f'{self.thisid}-不存在任务,等待3秒')
def process_start(lock): def process_start(lock, thisid):
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
keyword = DownLoad(lock) keyword = DownLoad(lock, thisid)
# 生产 # 生产
loop.run_until_complete(keyword.on_start()) loop.run_until_complete(keyword.on_start())
...@@ -113,7 +114,7 @@ if __name__ == '__main__': ...@@ -113,7 +114,7 @@ if __name__ == '__main__':
lock = Lock() lock = Lock()
l = [] l = []
for i in range(5): for i in range(5):
p = Process(target=process_start, args=(lock,)) p = Process(target=process_start, args=(lock, i))
p.start() p.start()
l.append(p) l.append(p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment