Django multiprocessing and database connections

前端 未结 9 863
挽巷
挽巷 2020-11-28 03:16

Background:

I\'m working a project which uses Django with a Postgres database. We\'re also using mod_wsgi in case that matters, since some of my web searches have m

9条回答
  •  醉酒成梦
    2020-11-28 03:46

    If you're also using connection pooling, the following worked for us, forcibly closing the connections after being forked. Before did not seem to help.

    from django.db import connections
    from django.db.utils import DEFAULT_DB_ALIAS
    
    connections[DEFAULT_DB_ALIAS].dispose()
    

提交回复
热议问题