phi*_*con 8 python iis django pdfkit
我使用pdfkit和wkhtmltopdf生成pdf文档.当我生成第一个pdf时,一切都很好.当我快速(在5秒内)生成另一个我得到错误[Errno 9]错误的文件描述符.如果我关闭错误(退回浏览器)并再次打开,它将创建pdf.
我的views.py
config = pdfkit.configuration(wkhtmltopdf='C:/wkhtmltopdf/bin/wkhtmltopdf.exe')
pdfgen = pdfkit.from_url(url, printname, configuration=config)
pdf = open(printname, 'rb')
response = HttpResponse(pdf.read())
response['Content-Type'] = 'application/pdf'
response['Content-disposition'] = 'attachment ; filename =' + filename
pdf.close()
return response
Run Code Online (Sandbox Code Playgroud)
也许重要的说明:我在IIS8上运行这个站点,当从命令行(python manage.py runserver)运行时,错误不存在.
有关如何处理此错误的任何指导都会很棒.