本文整理匯總了Python中gearman.GearmanClient.establish_connection方法的典型用法代碼示例。如果您正苦於以下問題:Python GearmanClient.establish_connection方法的具體用法?Python GearmanClient.establish_connection怎麽用?Python GearmanClient.establish_connection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gearman.GearmanClient
的用法示例。
在下文中一共展示了GearmanClient.establish_connection方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_gearman_status
# 需要導入模塊: from gearman import GearmanClient [as 別名]
# 或者: from gearman.GearmanClient import establish_connection [as 別名]
def get_gearman_status(job_handle):
try:
# Query gearmand
client = GearmanClient(settings.GEARMAN_SERVERS)
client.establish_connection(client.connection_list[0])
# configure the job to request status for - the last four is not needed for Status requests.
j = gearman.job.GearmanJob(client.connection_list[0], str(job_handle), None, None, None)
# create a job request
jr = gearman.job.GearmanJobRequest(j)
jr.state = 'CREATED'
# request the state from gearmand
res = client.get_job_status(jr)
# the res structure should now be filled with the status information about the task
return res
except:
print "Unexpected error:", sys.exc_info()[0]
return -1