Forums

flask / wsgi / coloredlogs install problem

Documenting somewhere that I had a major problem when trying to import code that I used with pythonanywhere, flask, and the 'coloredlogs' module. The method coloredlogs.install() caused a ton of issues that made it seem like monstrous amounts of RAM were being used that weren't - mostly because of an errant log file.

I was getting errors such as the following:

2018-09-12 15:35:13 DAMN ! worker 1 (pid: 14) died, killed by signal 9 :( trying respawn ...
2018-09-12 15:35:13 Respawned uWSGI worker 1 (new pid: 17)
2018-09-12 15:35:13 spawned 2 offload threads for uWSGI worker 1

But nothing related to "HARIKIRI".

Recommendation from the support staff was to try disabling coloredlogs, which fixed many of my issues.

Just to clarify what we think was going on here: the Flask web app was using lots of memory when it started up, but there was nothing in @cleartonic's code that you'd expect to cause that. The memory spike happened when there was a call to logging.info in a view; logging.info outside a view (at module level) didn't cause any problems. This, of course, made it really hard to debug -- the debugging tools themselves were the trigger for the problem!

Removing the import/install of the coloredlogs module fixed the issue, so it looks like what was happening was that somehow the hooks that that module puts into the logging system were being made to use up excessive amounts of memory when run inside a Flask view, specifically under uWSGI (the code worked fine on @cleartonic's own machine).