File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
graalpython/com.oracle.graal.python.test/src/com/oracle/graal/python/test Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -84,18 +84,28 @@ public class PythonTests {
84
84
public static void enterContext (String ... newArgs ) {
85
85
PythonTests .outArray .reset ();
86
86
PythonTests .errArray .reset ();
87
- if (context != null ) {
88
- closeContext ();
89
- }
87
+ Context prevContext = context ;
90
88
context = Context .newBuilder ().engine (engine ).allowAllAccess (true ).arguments ("python" , newArgs ).build ();
91
89
context .initialize ("python" );
90
+ if (prevContext != null ) {
91
+ closeContext (prevContext );
92
+ }
92
93
context .enter ();
93
94
}
94
95
96
+ private static void closeContext (Context ctxt ) {
97
+ try {
98
+ ctxt .leave ();
99
+ } catch (RuntimeException e ) {
100
+ }
101
+ ctxt .close ();
102
+ }
103
+
95
104
public static void closeContext () {
96
- context .leave ();
97
- context .close ();
98
- context = null ;
105
+ if (context != null ) {
106
+ closeContext (context );
107
+ context = null ;
108
+ }
99
109
}
100
110
101
111
public static void assertBenchNoError (Path scriptName , String [] args ) {
You can’t perform that action at this time.
0 commit comments