Developer/모아두기

[uwsgi,psycopg2] uwsgi multi-worker 에러

LeeJaeng 2016. 4. 25. 11:26
python flask + uwsgi + postgresql(sqlalchemy, psycopg2) 를 쓰고 있는데
uwsgi setting 에서 workers를 늘리면 다음과 같은 에러가 발생한다.

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL error: decryption failed or bad record mac


문제 해결법은 다음과 같다.


uwsgi 설정을 기록하는 .ini 파일에 다음의 옵션을 추가한다.

     lazy-apps = true

  • uWSGI tries to (ab)use the Copy On Write semantics of the fork() call whenever possible. By default it will fork after having loaded your applications to share as much of their memory as possible. If this behavior is undesirable for some reason, use the lazy-apps option. This will instruct uWSGI to load the applications after each worker’s fork(). Beware as there is an older options named lazy that is way more invasive and highly discouraged (it is still here only for backward compatibility)

즉 lazy-apps를 true로 바꾼다는 것은 worker가 applicaition을 fork()가 끝난 뒤에 load한다는 것이다.