@@ -109,27 +109,37 @@ protected int frameIndex() {
109
109
return -1 ;
110
110
}
111
111
112
+ /**
113
+ * As long as a subclass wants to run multiple callables in a single action, it can return
114
+ * {@code true} here.
115
+ */
116
+ protected boolean proceed () {
117
+ return false ;
118
+ }
119
+
112
120
@ Override
113
121
public final void execute (PythonContext context ) {
114
122
Object callable = callable ();
115
- if (callable != null ) {
116
- Object [] arguments = arguments ();
117
- Object [] args = PArguments .create (arguments .length + CallRootNode .ASYNC_ARG_COUNT );
118
- PythonUtils .arraycopy (arguments , 0 , args , PArguments .USER_ARGUMENTS_OFFSET + CallRootNode .ASYNC_ARG_COUNT , arguments .length );
119
- PArguments .setArgument (args , CallRootNode .ASYNC_CALLABLE_INDEX , callable );
120
- PArguments .setArgument (args , CallRootNode .ASYNC_FRAME_INDEX_INDEX , frameIndex ());
123
+ do {
124
+ if (callable != null ) {
125
+ Object [] arguments = arguments ();
126
+ Object [] args = PArguments .create (arguments .length + CallRootNode .ASYNC_ARG_COUNT );
127
+ PythonUtils .arraycopy (arguments , 0 , args , PArguments .USER_ARGUMENTS_OFFSET + CallRootNode .ASYNC_ARG_COUNT , arguments .length );
128
+ PArguments .setArgument (args , CallRootNode .ASYNC_CALLABLE_INDEX , callable );
129
+ PArguments .setArgument (args , CallRootNode .ASYNC_FRAME_INDEX_INDEX , frameIndex ());
121
130
122
- try {
123
- GenericInvokeNode .getUncached ().execute (context .getAsyncHandler ().callTarget , args );
124
- } catch (RuntimeException e ) {
125
- // we cannot raise the exception here (well, we could, but CPython
126
- // doesn't), so we do what they do and just print it
127
-
128
- // Just print a Python-like stack trace; CPython does the same (see
129
- // 'weakrefobject.c: handle_callback')
130
- ExceptionUtils .printPythonLikeStackTrace (e );
131
+ try {
132
+ GenericInvokeNode .getUncached ().execute (context .getAsyncHandler ().callTarget , args );
133
+ } catch (RuntimeException e ) {
134
+ // we cannot raise the exception here (well, we could, but CPython
135
+ // doesn't), so we do what they do and just print it
136
+
137
+ // Just print a Python-like stack trace; CPython does the same (see
138
+ // 'weakrefobject.c: handle_callback')
139
+ ExceptionUtils .printPythonLikeStackTrace (e );
140
+ }
131
141
}
132
- }
142
+ } while ( proceed ());
133
143
}
134
144
}
135
145
0 commit comments