本文整理汇总了Python中gearman.GearmanClient.dispatch_background_task方法的典型用法代码示例。如果您正苦于以下问题:Python GearmanClient.dispatch_background_task方法的具体用法?Python GearmanClient.dispatch_background_task怎么用?Python GearmanClient.dispatch_background_task使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gearman.GearmanClient
的用法示例。
在下文中一共展示了GearmanClient.dispatch_background_task方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: download
# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import dispatch_background_task [as 别名]
def download(request):
if "folder" not in request.GET or "title" not in request.GET or "url" not in request.GET:
return HttpResponse("failed to enqueue, one or more params missing")
folder = request.GET["folder"]
name = request.GET["title"]
video_url = request.GET["url"]
if folder =='' or name =='' or video_url=='':
return HttpResponse("failed to enqueue")
info = Info()
video_id = info.add_to_queue(folder,video_url,name)
#outtmpl="%s/%s" % (folder,name)
folder="%s/%s" %(settings.DOWNLOAD_PATH,folder)
d = {'folder':folder,'name':name,'url':video_url,'id':video_id}
client = GearmanClient(["127.0.0.1"])
res = client.dispatch_background_task("download", d)
return HttpResponse("enqueued video for successfully")
示例2: GearmanClient
# 需要导入模块: from gearman import GearmanClient [as 别名]
# 或者: from gearman.GearmanClient import dispatch_background_task [as 别名]
import time
from gearman import GearmanClient, Task
client = GearmanClient(["127.0.0.1"])
for i in range(5):
client.dispatch_background_task('speak', i)
print 'Dispatched %d' % i
time.sleep(1)