|
@@ -9,6 +9,10 @@ import threading
|
|
|
from dongri_task import *
|
|
|
from collections import deque
|
|
|
import json
|
|
|
+from concurrent.futures import ThreadPoolExecutor
|
|
|
+
|
|
|
+# 全局线程池,限制最大线程数为1
|
|
|
+executor = ThreadPoolExecutor(max_workers=1)
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
socketio = SocketIO(app)
|
|
@@ -126,7 +130,7 @@ def handle_restart_game():
|
|
|
os.execl(python, python, *sys.argv, '--reset')
|
|
|
|
|
|
def restart_game():
|
|
|
- global isGameBegin, autoTask
|
|
|
+ global isGameBegin
|
|
|
isGameBegin = False
|
|
|
while True:
|
|
|
task_close_game()
|
|
@@ -208,17 +212,23 @@ def auto_task(data):
|
|
|
else:
|
|
|
isMaxCollect = data['maxCollect']
|
|
|
send_status(f'开始自动模式')
|
|
|
+ executor.submit(add_auto_task, isMaxCollect)
|
|
|
+ '''
|
|
|
autoTask = threading.Thread(target=add_auto_task, args=(isMaxCollect,))#启动线程往里面添加任务
|
|
|
autoTask.daemon = True
|
|
|
autoTask.start()
|
|
|
+ '''
|
|
|
|
|
|
@socketio.on('begin_auto_participate')
|
|
|
def handle_auto_participate():
|
|
|
global autoTask
|
|
|
send_status(f'开始自动集结模式')
|
|
|
+ executor.submit(auto_participate)
|
|
|
+ '''
|
|
|
autoTask = threading.Thread(target=auto_participate)#启动线程往里面添加任务
|
|
|
autoTask.daemon = True
|
|
|
autoTask.start()
|
|
|
+ '''
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|