-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isolating execution via separate contexts #208
Comments
Hi @mashdragon, thanks for taking the time to check out PythonMonkey! This is definitely on our roadmap and something we will get to in the future |
I think it's a good idea, quickjs did it |
This is definitely an interesting idea. It does raise some complex questions like - what happens when a JS variable is shared from one context to another via the underlying Python code? The GC requirements in PythonMonkey can get very interesting because we have to interoperate with both interpreters at the same time. One of the questions that pops is -- do we care about complete isolation, meaning a new SpiderMonkey JSContext *cx, or is symbol-level isolation enough? Providing a new global object and standard classes (Array, Object, etc) would be pretty easy, along with an isolated module context via ctx-module. But this type of incomplete isolation might have interesting prototype-walking attacks, like I like the QuickJS interface. If we do this, we will also make it possible to emulate the NodeJS |
I think what we want is separate realms. We can call 'em contexts from the users' POV. http://www.carolinecullen.com/spidermonkeynotes/notes/runtime.html |
I just ran into PythonMonkey, and so far it's been great! I just wanted to bump this issue because I also would find the ability to create separate contexts extremely useful. |
Describe your feature request here.
It does not seem like there is a feature in PythonMonkey to run JavaScript scripts or evals in isolation after importing the module. This means that I have to keep track of the JavaScript state myself and perform any cleanup manually on objects that pollute the
globalThis
space.It would be nice if there were a way to isolate execution so that separate scripts run in separate environments, just like how scripts in the web are isolated to their pages.
Maybe this would appear as a
pm.context()
function to get a new JavaScript execution context.Code example
The text was updated successfully, but these errors were encountered: