Skip to content

Commit 3f10a7d

Browse files
committed
Reset the state
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.
1 parent 136403b commit 3f10a7d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

example/quick-start/quick-start.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@ int main(int argc, char* argv[]) {
4343
// Execute Python functions and activate Python entry points
4444
// ==========================================================
4545
if (yt_run_Function("print_hello_world") != YT_SUCCESS) {
46+
fprintf(stderr, "ERROR: yt_run_Function failed!\n");
4647
exit(EXIT_FAILURE);
4748
}
4849

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

5355
// Activate Python prompt
5456
if (yt_run_InteractiveMode("LIBYT_STOP") != YT_SUCCESS) {
57+
fprintf(stderr, "ERROR: yt_run_InteractiveMode failed!\n");
5558
exit(EXIT_FAILURE);
5659
}
5760

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

73+
// Free and reset the state
74+
if (yt_free() != YT_SUCCESS) {
75+
fprintf(stderr, "ERROR: yt_free() failed!\n");
76+
exit(EXIT_FAILURE);
77+
}
78+
7079
// =======================================
7180
// Finalize libyt
7281
// =======================================

0 commit comments

Comments
 (0)