14
14
__all__ = [
15
15
'get_current' , 'get_main' , 'create' , 'list_all' , 'is_shareable' ,
16
16
'Interpreter' ,
17
- 'InterpreterError' , 'InterpreterNotFoundError' ,
18
- 'ExecFailure' , 'CallFailure' ,
17
+ 'InterpreterError' , 'InterpreterNotFoundError' , 'ExecutionFailed' ,
19
18
'NotShareableError' ,
20
19
'create_queue' , 'Queue' , 'QueueEmpty' , 'QueueFull' ,
21
20
]
@@ -44,7 +43,11 @@ def __getattr__(name):
44
43
{formatted}
45
44
""" .strip ()
46
45
47
- class _ExecFailure (RuntimeError ):
46
+ class ExecutionFailed (RuntimeError ):
47
+ """An unhandled exception happened during execution.
48
+
49
+ This is raised from Interpreter.exec() and Interpreter.call().
50
+ """
48
51
49
52
def __init__ (self , excinfo ):
50
53
msg = excinfo .formatted
@@ -68,14 +71,6 @@ def __str__(self):
68
71
)
69
72
70
73
71
- class ExecFailure (_ExecFailure ):
72
- """Raised from Interpreter.exec() for unhandled exceptions."""
73
-
74
-
75
- class CallFailure (_ExecFailure ):
76
- """Raised from Interpreter.call() for unhandled exceptions."""
77
-
78
-
79
74
def create ():
80
75
"""Return a new (idle) Python interpreter."""
81
76
id = _interpreters .create (isolated = True )
@@ -176,18 +171,18 @@ def exec(self, code, /):
176
171
177
172
There is no return value.
178
173
179
- If the code raises an unhandled exception then an ExecFailure
180
- is raised, which summarizes the unhandled exception. The actual
181
- exception is discarded because objects cannot be shared between
182
- interpreters.
174
+ If the code raises an unhandled exception then an ExecutionFailed
175
+ exception is raised, which summarizes the unhandled exception.
176
+ The actual exception is discarded because objects cannot be
177
+ shared between interpreters.
183
178
184
179
This blocks the current Python thread until done. During
185
180
that time, the previous interpreter is allowed to run
186
181
in other threads.
187
182
"""
188
183
excinfo = _interpreters .exec (self ._id , code )
189
184
if excinfo is not None :
190
- raise ExecFailure (excinfo )
185
+ raise ExecutionFailed (excinfo )
191
186
192
187
def call (self , callable , / ):
193
188
"""Call the object in the interpreter with given args/kwargs.
@@ -199,15 +194,15 @@ def call(self, callable, /):
199
194
200
195
If the callable raises an exception then the error display
201
196
(including full traceback) is send back between the interpreters
202
- and a CallFailedError is raised, much like what happens with
203
- Interpreter.exec().
197
+ and an ExecutionFailed exception is raised, much like what
198
+ happens with Interpreter.exec().
204
199
"""
205
200
# XXX Support args and kwargs.
206
201
# XXX Support arbitrary callables.
207
202
# XXX Support returning the return value (e.g. via pickle).
208
203
excinfo = _interpreters .call (self ._id , callable )
209
204
if excinfo is not None :
210
- raise CallFailure (excinfo )
205
+ raise ExecutionFailed (excinfo )
211
206
212
207
def call_in_thread (self , callable , / , args = None , kwargs = None ):
213
208
"""Return a new thread that calls the object in the interpreter.
0 commit comments