现在,我编写了一段代码,当用户使用django_background_任务库下载文件时,会在5秒钟后删除临时文件夹
我必须用APScheduler库替换它,因为heroku只支持APScheduler。 但我不知道如何安排在5秒后调用它时运行的作业
这是代码
@background(schedule=5)
def task_delete_zipfile(filePath):
if os.path.exists(filePath):
shutil.rmtree(filePath)
logging.info("successfully deleted")
else:
logging.info("unable to delete")
zipdir = condown(idx)#returns directory after creating the temp directory
if os.path.exists(zipdir):
with open(zipdir, 'rb') as fh:
response = HttpResponse(fh.read(), content_type="multipart/form-data")
response['Content-Disposition'] = 'inline; filename*=UTF-8\'\'%s' % urllib.parse.quote(os.path.basename(zipdir).encode('utf-8'))
task_delete_zipfile(os.path.dirname(zipdir))
return response
raise Http404
提前谢谢
目前没有回答
相关问题 更多 >
编程相关推荐