Question on multiple Python users in one application

Jolly Good Spam myspamacct at earthlink.net
Thu Oct 6 16:59:17 EDT 2016


Hello. Please pardon a newbie question.

I have a Windows multi-user program that can be used by an arbitrary number 
of users at once. They can work independently, or they can share data at the 
file or even variable level if they want. I want to give them the ability to 
write Python programs within this environment. So I intend to embed CPython 
access in the program.

The basic embedding of CPython seems straight forward. But since I have 
multiple users, each needs their own Python sandbox, so if they all compile 
programs with variable 'spam', it doesn't collide. Of course they can all 
have different programs running at the same time too.

I think I need to do some behind-the-scenes thread management and possibly 
namespace management to allow this to work correctly. But this is where I'm 
confused, and not sure where to start. I know how to tell my users apart. 
The program is multi-threaded, but there is not a direct correspondence 
between a user and a thread; a single user can switch threads, but I know 
when this happens.

Can someone please suggest what I should be looking at and doing to be able 
to effectively run multiple independent Pythons in a single program?

Thank you for your help!

        Loren




More information about the Python-list mailing list