defer-examples.py

来自「大型多人在线游戏开发,该书光盘上附带的源码」· Python 代码 · 共 24 行

PY
24 行
字号
def printResult(x):    print 'result:',x# remote method callremoteObject.callRemote("test").addCallback(printResult)# database interactiondbInterface.runQuery("select * from random_table").addCallback(printResult)# threadpool executiondef myMethod(a, b, c):    return a + b + cdeferToThread(myMethod, 1, 2, 3).addCallback(printResult)# Remote method calls that invoke a database connection and wait until the# database is done returning its query before turning the query into a string# and then sending the string as the result of the remote method call.class MyClass(Referenceable):    def remote_doIt(self):        return self.databaseConnector.runQuery(            "select * from foo").addCallback(str)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?