本文整理匯總了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)