Python and multi-threading. Is it a good idea? What are some ways to get some Python code to run in a parallel way. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Python and multi-threading. Is it a good idea? What are some ways to get some Python code to run in a parallel way.

28th Mar 2018, 1:04 AM
Ashwani Kumar Kamal
Ashwani Kumar Kamal - avatar
2 Answers
+ 4
An example using multprocessing: https://code.sololearn.com/cPyfXZGRo5sr/?ref=app On SoloLearn there isn't enough memory for our codes to import the full module, so the ".dummy" import allows me to write code for the module (which then runs serially). Note that the Global Interpreter Lock (GIL) matters with simultaneously executing code; I've added another answer to this effect.
28th Mar 2018, 4:29 AM
Kirk Schafer
Kirk Schafer - avatar
+ 4
Grok the GIL: How to write fast and thread-safe Python We explore Python's global interpreter lock and learn how it affects multithreaded programs. https://opensource.com/article/17/4/grok-gil
28th Mar 2018, 4:36 AM
Kirk Schafer
Kirk Schafer - avatar