This may be one of the strangest issues I've come across...
I'm running a web server with Gunicorn using Uvicorn workers and Starlette, and for the most part it works great. However during periods of high traffic, I get the following error while it's trying to process the results of a SQL query:
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-3770' coro=<process_invoice() done, defined at /home/*/PycharmProjects/*/routes/invoices.py:100> exception=IndexError('tuple index out of range')>
Traceback (most recent call last):
File "/home/*/PycharmProjects/*/routes/invoices.py", line 134, in process_invoice
# add completeBefore and completeAfter
^^^^^^^^^^^^^
IndexError: tuple index out of range
and here is the code in question
# add completeBefore and completeAfter
invoice.completeBefore = delv_win_results[0]['completeBefore']
invoice.completeAfter = delv_win_results[0]['completeAfter']
invoice.appearance = delv_win_results[0]['appearance']
where invoice is a pydantic model. This is part of the coroutine process_invoice which runs 4 queries and updates our pydantic model.
The interpreter clearly thinks the comment is throwing an error, what could be happening here? Could it be trying to interpret some of the comment's contents?
Info:
- OS: Ubuntu 22.04LTS
- Python 3.11
- Conda 21.3.0
- aiomysql(pypi package) 0.1.1
- redis(pypi package) 4.5.1