3👍
If catch-all exception handling is not catching this, then either you are not running this code, or the exception in production happens outside of the try block. The 500 could even be due to an error completely outside python.
Introduce a deliberate error in this section of code and see if you see a change in behaviour in production. That at least lets you rule out the possibility of running stale code.
2👍
Thanks to Martijn Pieters’s comments and questions, I found some errors which resutled in the strange behaviour:
-
The
except subprocess.CalledProcessError as e:
part contained some unicode-conversions which run fine on system a and caused problems on system b. Therefore, a UnicodeConversionError was raised in my exception handling and this caused the 500 error since it was not caught. -
An other problem in the posted code is, that
unicode(sys.exc_info(), "utf-8")
is raising an exception as well, becausesys.exc_info()
returns a tuple which is correctly converted to a string when using thestr()
-method, butunicode()
can only deal with strings and not with tuples. One work around which did the job for me isunicode(str(...))
.
Thanks to everyone who spent time in solving this question!
- [Django]-Django Query Performance Filtering Vs Foreign Key Set Lookup
- [Django]-How can I sign a file with PKCS11 in Python?
- [Django]-How can I create sophisticated Django Model Validation for Django Admin?
- [Django]-How to use check_password function in django