server exits with code -1 after a while

I have a function that often seem to stop unexpectedly. If I r-start the server, all is working.
Here is the main part of the function :

query = """
FROM `azure-pricing`
GROUP BY `meterName`
LIMIT 0, 1000

print("query =", query)

result = cursor_cloud.fetchall()

The server stopped unexpectedly with code -1

This happens after while. Is there some leak in memory or something of that kind for my runserver to stop ?

(I’m using PyCharm)

Look to see if there are any error logs available. If not, it might be worth running runserver from the command prompt to have those logs available to you. (Or, redirect those terminal logs to files for later inspection.)

Also, if you run runserver independently, you can use tools like ps (or top) to give you an idea of resource usage.

Finally, if you know that the error is occurring in this function, you can wrap this in a try / except block to capture any error that may be thrown to display the errors.