I'm facing an issue that I haven't been able to resolve on my own. The problem involves using GameThreads with the pymysql module. Specifically, I'm loading a plugin that fetches queries from a MariaDB database, and I've noticed that the results take significantly longer than running them in the main thread.
I've tested using following snippet:
Syntax: Select all
import pymysql
import time
import threading
connection = pymysql.connect(
host="",
user="",
password="",
db="",
charset="",
cursorclass=pymysql.cursors.DictCursor,
)
cursor = connection.cursor()
def do_thread():
current_time = time.time()
cursor.execute("...")
result = cursor.fetchall()
print(len(result))
now = time.time()
print(f"Time: {now - current_time}")
thread = threading.Thread(target=do_thread)
thread.start()
I've ran the code through:
- Windows Python3
- Windows CS:S Source.Python
Windows Python3:
Code: Select all
2445
Time: 0.18452095985412598
Windows CS:S Source.Python:
Code: Select all
2445
Time: 27.85248613357544
Additional Note - When running it outside a thread in Windows CS:S Source.Python, the output looks like this:
2445
Time: 0.09724783897399902
Version:
Code: Select all
sp info
[Source.Python]
IMPORTANT: Please copy the full output.
--------------------------------------------------------
Checksum : fe51d1cec1f41c7e6aa1434392a82db3
Date : 2023-07-19 18:09:17.378787
OS : Windows-10-10.0.19041
Game : css
SP version : 720
Github commit : ad71981b892d4324cf49a07005a858c7682ffe92
Server plugins:
00: Source.Python, (C) 2012-2021, Source.Python Team.
01: Tickrate_Enabler 0.4, Didrole
SP plugins:
00: mysql
--------------------------------------------------------
Not sure if this issue is windows specific. Any help would be appreciated.