File tree Expand file tree Collapse file tree 1 file changed +1
-27
lines changed
Expand file tree Collapse file tree 1 file changed +1
-27
lines changed Original file line number Diff line number Diff line change 2222namespace py = pybind11;
2323
2424Message Reader_readNext (Reader& reader) {
25- Message msg;
26- Result res;
27-
28- // TODO: There is currently no readNextAsync() version for the Reader.
29- // Once that's available, we should also convert these ad-hoc loops.
30- while (true ) {
31- Py_BEGIN_ALLOW_THREADS
32- // Use 100ms timeout to periodically check whether the
33- // interpreter was interrupted
34- res = reader.readNext (msg, 100 );
35- Py_END_ALLOW_THREADS
36-
37- if (res != ResultTimeout) {
38- // In case of timeout we keep calling receive() to simulate a
39- // blocking call until a message is available, while breaking
40- // every once in a while to check the Python signal status
41- break ;
42- }
43-
44- if (PyErr_CheckSignals () == -1 ) {
45- PyErr_SetInterrupt ();
46- return msg;
47- }
48- }
49-
50- CHECK_RESULT (res);
51- return msg;
25+ return waitForAsyncValue<Message>([&](ReadNextCallback callback) { reader.readNextAsync (callback); });
5226}
5327
5428Message Reader_readNextTimeout (Reader& reader, int timeoutMs) {
You can’t perform that action at this time.
0 commit comments