Django multiprocessing and database connections

前端 未结 9 853
挽巷
挽巷 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:51

    If all you need is I/O parallelism and not processing parallelism, you can avoid this problem by switch your processes to threads. Replace

    from multiprocessing import Process
    

    with

    from threading import Thread
    

    The Thread object has the same interface as Procsess

提交回复
热议问题