Subject: Re: [boost] Boost.Python sandox or multiple interpreters
From: Stefan Seefeld (stefan_at_[hidden])
Date: 2017-01-13 13:02:44
On 13.01.2017 12:46, David Bellot wrote:
>>> - or encapsulate each plugin in an independent "environment" ?
>> Hard to tell without knowing these plugins. Right now it sounds like
>> that's a question only you can answer. :-)
> âThe plugins are quite simple in fact:
> The Python code define a few functions like
> def on_value_update(âx):
> blah blah blah
> return foobar
> and they can have global variables (if it's a problem I can forbid user's
> to use those global variables in their plugins).
For avoidance of doubt: "global variables" aren't variables in
module-scope (they are still "local" to the module, and don't cause any
> Each plugin is defined in a .py file and at runtime I load all those files,
> one after each other.
That sounds all good. Each plugin corresponds to a Python module (which
is an object), and you can call module-level functions (such as
'on_value_update') on that object as if it was a method. So if you keep
a list of module objects in your C++ runtime, you can access their
methods without any global functions colliding. (See
for how to embed Python code into your C++ app.)
In case that doesn't help, can you explain where in your current setup
the plugin methods overwrite each other as they are loaded ?
-- ...ich hab' noch einen Koffer in Berlin...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk