Skip to content

Commit

Permalink
Merge pull request #396 from DerThorsten/fixes
Browse files Browse the repository at this point in the history
capture variables by value in reply lambda
  • Loading branch information
JohanMabille authored Mar 26, 2024
2 parents 8df00b0 + d8caef5 commit 4798906
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ON \
-DXEUS_EMSCRIPTEN_WASM_BUILD=ON \
-Dnlohmann_json_DIR=$MAMBA_ROOT_PREFIX/share/cmake/nlohmann_json \
..
make -j${{ steps.cpu-cores.outputs.count }}
19 changes: 10 additions & 9 deletions src/xkernel_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,35 +241,36 @@ namespace xeus

xrequest_context request_context(request.header(), c, request.identities());
execute_request_config config { silent, store_history, allow_stdin };
int execution_count = 1;
std::string status;
auto reply_callback = [&](nl::json reply)

auto reply_callback = [this, request_context, config, stop_on_error, code](nl::json reply)
{
int execution_count = 1;
execution_count = reply.value("execution_count", 1);
std::string status;
status = reply.value("status", "error");
nl::json metadata = get_metadata();

send_reply(
request.identities(),
request_context.id(),
"execute_reply",
request.header(),
request_context.header(),
std::move(metadata),
std::move(reply),
c
request_context.origin()
);

if (!silent && store_history)
if (!config.silent && config.store_history)
{
p_history_manager->store_inputs(0, execution_count, code);
}
if (!silent && status == "error" && stop_on_error)
if (!config.silent && status == "error" && stop_on_error)
{
constexpr long polling_interval = 50;
p_server->abort_queue(std::bind(&xkernel_core::abort_request, this, _1), polling_interval);
}

// idle
publish_status("idle", request_context.header(), request_context.origin());
publish_status(request_context.header(), "idle", request_context.origin());
};

p_interpreter->execute_request(
Expand Down

0 comments on commit 4798906

Please sign in to comment.