python Global Interpreter Lock GIL problem

后端 未结 2 902
轮回少年
轮回少年 2021-01-20 16:05

I want to provide a service on the web that people can test out the performance of an algo, which is written in python and running on the linux machine

basically wha

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 17:07

    The GIL is per-process. If you start multiple python processes, each will have its own GIL that prevents the interpreter(s) in this specific process from running more than one thread at a time. But independent processes can run at the same time.

    Also, multiple threads inside one Python process do take turns on running (rather frequently, IIRC once per hundred opcode instructions or a few dozen milliseconds depending on the version), so it's not like the GIL prevents concurrency at all - it just prevents multi-threading.

提交回复
热议问题