Python context isolation broken?
Offen
@lukasstadler arbeitet bereits daran.
Seit 02.10.2018.
- Vorherrschende Sprache
- Python
- Sterne
- 1.6k
- Forks
- 155
- Ø Merge
- 9 Std. 42 Min.
- Gemergte PRs (30 T.)
- 36
Beschreibung
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine;
import org.graalvm.polyglot.Source;
/** Created by revin on Oct.1,2018. */
public class BugReport{
public void trace(Object x){System.out.println(x);}
public static void main(String...args)throws Exception{
Engine engine=Engine.create();
Context c0=Context.newBuilder().allowIO(true).engine(engine).build();
Context c1=Context.newBuilder().allowIO(true).engine(engine).build();
Source source=Source.newBuilder("python",
"import polyglot\n"+
"try:bug.trace(\"SHOULD NOT SEE THIS\")\nexcept:pass\n"+
"bug=polyglot.import_value(\"bug\")\n"
,"bugReport.py").build();
BugReport bug=new BugReport();
long nano0=System.nanoTime();c0.getPolyglotBindings().putMember("bug",bug);c0.eval(source);
long nano1=System.nanoTime();c1.getPolyglotBindings().putMember("bug",bug);c1.eval(source);
long nano2=System.nanoTime();System.out.println((nano1-nano0)/1000_000+" ms without init, "+(nano2-nano1)/1000_000+" ms after init");
}
}

expected output: none
actual output: "SHOULD NOT SEE THIS"
as you can see from the simplified code above:
it creates two separate contexts, run the same code in each one of them
but it seems somehow the global variable bug leaked from the first context into the second one
am I misunderstood something here? how can I achieve performant context isolation?
context initialization(even if they use the same engine instance underneath) seems very heavy
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Bewertung
Dieses Issue wurde noch nicht bewertet.