本文整理汇总了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