Multiple independent Python interpreters in a C/C++ program?

Matthieu Brucher matthieu.brucher at gmail.com
Fri Apr 11 13:27:23 EDT 2008


2008/4/11, skip at pobox.com <skip at pobox.com>:
>
> This question was posed to me today.  Given a C/C++ program we can clearly
> embed a Python interpreter in it.  Is it possible to fire up multiple
> interpreters in multiple threads?  For example:
>
>     C++ main
>         thread 1
>             Py_Initialize()
>         thread 2
>             Py_Initialize()
>
> Do I wind up with two completely independent interpreters, one per thread?
> I'm thinking this doesn't work (there are bits which aren't thread-safe
> and
> are only protected by the GIL), but wanted to double-check to be sure.
>
> Thanks,
>
> Skip
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Hi,

You will only have one the different static Python variables, so this is not
possible.

Matthieu
-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080411/e33ea408/attachment.html>


More information about the Python-list mailing list