How do threads work in Python, and what are common Python-threading specific pitfalls?

前端 未结 7 1357
一个人的身影
一个人的身影 2020-11-27 11:13

I\'ve been trying to wrap my head around how threads work in Python, and it\'s hard to find good information on how they operate. I may just be missing a link or something,

相关标签:
7条回答
  • 2020-11-27 11:50

    One easy solution to the GIL is the multiprocessing module. It can be used as a drop in replacement to the threading module but uses multiple Interpreter processes instead of threads. Because of this there is a little more overhead than plain threading for simple things but it gives you the advantage of real parallelization if you need it. It also easily scales to multiple physical machines.

    If you need truly large scale parallelization than I would look further but if you just want to scale to all the cores of one computer or a few different ones without all the work that would go into implementing a more comprehensive framework, than this is for you.

    0 讨论(0)
提交回复
热议问题