Simple multi-threading with SQLObject doesn't work
题
It stucks once I execute .getOne()
:
from sqlobject import *
import threading
sqlhub.processConnection = connectionForURI('mysql://user:password@localhost:3306/database')
class Player(SQLObject):
name = StringCol(length=64)
last_login = DateTimeCol()
create_date = DateTimeCol(default=DateTimeCol.now)
def act():
result = Player.selectBy(name='Zippo')
player = result.getOne()
print 'You will never see this message in console.'
threading.Thread(target=act).start()
解决方案 2
Unfortunately the problem was not related to SQLObject or Python. It was probably my computer or my MySQL server. Sorry for misquestioning everybody.
其他提示
could getOne be falling over, and you're just not seeing the exception? In this case you can specify a default result as an argument, or you could put it in a try/except clause.
What happens if you run it in a debugger?
there's not much info to go on here as we don't know what's in your database.
不隶属于 StackOverflow