Making Django go green

前端 未结 2 1807
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-04 12:45

I have a Django management command that makes thousands of TCP/UDP requests. I\'ve used Gevent to speed this up as I\'ve restructured my code to work as coroutines. The socket c

2条回答
  •  误落风尘
    2021-02-04 13:13

    The gevent monkey patcher will patch the standard library to be Greenlet friendly. This should take of a lot of common Django calls.

    from gevent import monkey; monkey.patch_all()
    

    As far as databases, normally the interfaces are blocking. If you use PostgreSQL look into psyco_gevent to monkey patch psycopg2 to cooperate with gevent.

提交回复
热议问题