python Global Interpreter Lock GIL problem

后端 未结 2 903
轮回少年
轮回少年 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:01

    If you are opening each script by invoking a new process; you will not run afoul of the GIL. Each process gets its own interpreter and therefore its own interpreter lock.

    0 讨论(0)
  • 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.

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