MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / doOneExecution

Function doOneExecution

lib/execution/sqs-execution-queue.ts:147–194  ·  view source on GitHub ↗
(
    queue: SqsWorkerMode,
    compilationEnvironment: CompilationEnvironment,
    persistentSender: PersistentEventsSender,
)

Source from the content-addressed store, hash-verified

145}
146
147async function doOneExecution(
148 queue: SqsWorkerMode,
149 compilationEnvironment: CompilationEnvironment,
150 persistentSender: PersistentEventsSender,
151) {
152 if (!persistentSender.isReadyForNewMessages()) {
153 logger.debug(
154 `Skipping execution message pull - WebSocket not ready or has ${persistentSender.getPendingAckCount()} pending acknowledgments`,
155 );
156 return;
157 }
158
159 const msg = await queue.pop();
160 if (msg?.guid) {
161 const startTime = Date.now();
162 try {
163 const executor = new LocalExecutionEnvironment(compilationEnvironment);
164 await executor.downloadExecutablePackage(msg.hash);
165 const result = await executor.execute(msg.params);
166
167 const endTime = Date.now();
168 const duration = endTime - startTime;
169
170 await sendResultViaWebsocket(persistentSender, msg.guid, result, duration);
171 } catch (e) {
172 // todo: e is undefined somehow?
173 logger.error(e);
174
175 const endTime = Date.now();
176 const duration = endTime - startTime;
177
178 await sendResultViaWebsocket(
179 persistentSender,
180 msg.guid,
181 {
182 code: -1,
183 stderr: [{text: 'Internal error when remotely executing'}],
184 stdout: [],
185 okToCache: false,
186 timedOut: false,
187 filenameTransform: f => f,
188 execTime: 0,
189 },
190 duration,
191 );
192 }
193 }
194}
195
196export function startExecutionWorkerThread(
197 ceProps: PropertyGetter,

Callers 2

doExecutionWork1Function · 0.85
doExecutionWork2Function · 0.85

Calls 7

executeMethod · 0.95
sendResultViaWebsocketFunction · 0.85
isReadyForNewMessagesMethod · 0.80
getPendingAckCountMethod · 0.80
errorMethod · 0.80
popMethod · 0.45

Tested by

no test coverage detected