I'm attempting to move my code to production and am having some challenges with debugging. I would like to see the error messages when the program crashes, but I'm not sure how to view them.
Here's the current situation:
When I run python manage.py qcluster from the command line, everything works as expected. However, when I set up AlwaysOnTasks and run python manage.py qcluster (and then close the console), my custom service.py script crashes about every two days.
I followed the instructions on this link:
https://help.pythonanywhere.com/pages/AlwaysOnTasks/
I used the following configuration as recommended:
bash
Copy code
python3.10 -u /path/to/script.py
and added flush=True to my print statements. Even then, no errors are logged.
As a test, I tried the following code in services_test.py:
def q_print(secs):
try:
1/0
except Exception as e:
print(e, flush=True)
print('service_test done!')
However, the error is not showing up in the "view task log". Currently, the script crashes roughly once every two days, so I'm eager to learn how to capture the error logs when it crashes.
Additionally, I've noticed multiple outputs like:
2023-08-13 11:14:28 - Task preparing to start
Aug 13 11:14:56 service_test done!
Aug 13 11:14:57 service_test done!
...
in the "view task log". Is this expected behavior?
I'd appreciate any guidance or suggestions. Thank you!