Simple multi-threading with SQLObject doesn't work
It stucks once I execute .getOne()
:
from sqlobject import *
import threading
sqlhub.processConnection = connectionFo开发者_如何学运维rURI('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()
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.
Unfortunately the problem was not related to SQLObject or Python. It was probably my computer or my MySQL server. Sorry for misquestioning everybody.
精彩评论