我有以下脚本执行了三次,但我不知道为什么
#!C:/Python38-32/python.exe
#script.py
from py_get_data_from_game import main
from multiprocessing import Pool
import connect_to_db
import mysql.connector
from mysql.connector import Error
connection = connect_to_db.connect()
user_names = []
passwords = []
print('START')
try:
connection = connect_to_db.connect()
if connection.is_connected():
sql_select_Query = "select * from players"
cursor = connection.cursor(dictionary=True)
cursor.execute(sql_select_Query)
records = cursor.fetchall()
for row in records:
user_names.append(row['user_name'])
passwords.append(row['password'])
except Error as e:
print("Error while connecting to MySQL", e)
finally:
if (connection.is_connected()):
cursor.close()
connection.close()
print("MySQL connection is closed")
if __name__ == '__main__':
pool = Pool(2) # two parallel jobs
results = pool.map(main, zip(user_names, passwords))
输出:
C:\scripts>script.py
START
MySQL connection is closed
START
MySQL connection is closed
START
MySQL connection is closed
蛊毒传说
相关分类