After adding logging to track execution time, I found out that my app actually takes 1-4 seconds from start of app (webhook received) to end of app (webhook sent out).
It seems completely random when the OSError occurs. At the end of my program, I send 2 webhooks to myself: The first is an info message, the second is a trade execution message. Sometimes when the OSError occurs, I will only receive the trade execution message and not the info message. And sometimes neither are received. An example of what the logs show for this error:
On server log:
SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /webhook (ip 10.0.0.66) !!!
uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 306] during POST /webhook (10.0.0.66)
On error log:
My run time seems very fast. The OSError seems to occur at the end of my app script. Could this maybe occur because I end my script with either "return 'success', 200" or "abort(400)"? I'm quite new to web app creation, so if there is a proper way to end the script please let me know.