Skip to content

Commit

Permalink
Reset the state
Browse files Browse the repository at this point in the history
We need to free it because it resets the state of the Python functions tracked by libyt.
The design of how API gets called is a bit weird. Will fix this in future update.
  • Loading branch information
cindytsai committed Aug 28, 2024
1 parent f4bb414 commit b3ef39a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions example/quick-start/quick-start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ int main(int argc, char* argv[]) {
// Execute Python functions and activate Python entry points
// ==========================================================
if (yt_run_Function("print_hello_world") != YT_SUCCESS) {
fprintf(stderr, "ERROR: yt_run_Function failed!\n");
exit(EXIT_FAILURE);
}

if (yt_run_FunctionArguments("print_args", 3, "\'1\'", "2", "3.0") != YT_SUCCESS) {
fprintf(stderr, "ERROR: yt_run_FunctionArguments failed!\n");
exit(EXIT_FAILURE);
}

// Activate Python prompt
if (yt_run_InteractiveMode("LIBYT_STOP") != YT_SUCCESS) {
fprintf(stderr, "ERROR: yt_run_InteractiveMode failed!\n");
exit(EXIT_FAILURE);
}

Expand All @@ -67,6 +70,12 @@ int main(int argc, char* argv[]) {
exit(EXIT_FAILURE);
}

// Free and reset the state
if (yt_free() != YT_SUCCESS) {
fprintf(stderr, "ERROR: yt_free() failed!\n");
exit(EXIT_FAILURE);
}

// =======================================
// Finalize libyt
// =======================================
Expand Down

0 comments on commit b3ef39a

Please sign in to comment.