Skip to content

Commit 27759d9

Browse files
authored
Docs: Add example for setting result in callback (#76)
1 parent 42d82aa commit 27759d9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/adding_awaits.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,10 @@ Now, we can use the result of `silly` in C:
9292
static int
9393
callback(PyObject *awaitable, PyObject *value)
9494
{
95-
printf("silly() returned: ");
96-
PyObject_Print(value, stdout, Py_PRINT_RAW);
97-
printf("\n");
95+
if (PyAwaitable_SetResult(awaitable, value) < 0) {
96+
return -1;
97+
}
98+
9899
return 0;
99100
}
100101

0 commit comments

Comments
 (0)