Is virtualenv a workaround for GIL?

40 views
Skip to first unread message

Haining Yu

unread,
Aug 15, 2017, 2:41:41 PM8/15/17
to virtualenv
Hi,

If two python programs are running in two virtual environments on the same machine, are they processed by the same Global Interpreter Lock? 

Thanks,
Haining

Carl Meyer

unread,
Aug 15, 2017, 3:14:20 PM8/15/17
to python-v...@googlegroups.com
On 08/15/2017 11:41 AM, Haining Yu wrote:
> If two python programs are running in two virtual environments on the
> same machine, are they processed by the same Global Interpreter Lock?

No. The GIL is per-interpreter, thus per-process. Two different Python
processes will each have their own GIL (and thus be able to run
concurrently on different CPU cores), even if they are running from the
same virtualenv.

So virtualenv is not a workaround for the GIL, it's irrelevant. But
running multiple Python processes is a workaround for the GIL.

Carl

signature.asc
Reply all
Reply to author
Forward
0 new messages