Forums

reportlab - turns to Error running WSGI application

Hello,

i run an app in an virtualenv, installed reportlab via pip. Inside the app i want to create a pdf file.

I then reloaded the application and tried do create the pdf via my app, but i ran into the following error.

2020-11-28 16:50:35,564: Error running WSGI application
2020-11-28 16:50:35,572: SystemError: <built-in function uwsgi_sendfile> returned a result with an error set
2020-11-28 16:50:35,572:   File "/home/****/.virtualenvs/****venv/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 148, in __call__
2020-11-28 16:50:35,573:     response = environ['wsgi.file_wrapper'](response.file_to_stream, response.block_size)

All other sides and functions are working as expected. Only the pdf file is not created.

[edit by admin: formatting]

Could you give the full traceback of the error?

Thats all what is logged in the server error log

2020-11-28 21:19:55,883: Error running WSGI application
2020-11-28 21:19:55,888: SystemError: <built-in function uwsgi_sendfile> returned a result with an error set
2020-11-28 21:19:55,888:   File "/home/BloodPressureOnline/.virtualenvs/bloodpressurevenv/lib/python3.8/site-packages/django/core/handlers/wsgi.py", line 148, in __call__
2020-11-28 21:19:55,888:     response = environ['wsgi.file_wrapper'](response.file_to_stream, response.block_size)
2020-11-28 21:19:56,350: Not Found: /favicon.ico

That's odd, I would have expected more. What code do you have in your view function?

Thats the view for the pdf

@login_required
def evaluationprint(request):

    buffer = io.BytesIO()
    pdf = canvas.Canvas(buffer)
    pdf.drawString(100, 100, "Test")

    pdf.showPage()
    pdf.save()

    buffer.seek(0)
    return FileResponse(buffer, as_attachment=False, filename='Auswertung.pdf')

Have a look at this forum post where the issue and the solution are discussed.

Thanks, problem solved