You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/11/14 07:07:42 UTC
[GitHub] [pulsar] jiazhai commented on issue #5634: Python consumer does not
accept receiver_queue_size=0
jiazhai commented on issue #5634: Python consumer does not accept receiver_queue_size=0
URL: https://github.com/apache/pulsar/issues/5634#issuecomment-553755867
In Cpp, `ConsumerImpl::receive(Message& msg)` supports `receiver_queue_size=0`.
but with `timeout` parameter, `ConsumerImpl::receive(Message& msg, int timeout)` not support.
But in python, the methods both with and without `timeout` parameter, finally calls into
`ConsumerImpl::receive(Message& msg, int timeout)`.
```
Message Consumer_receive(Consumer& consumer) {
Message msg;
Result res;
while (true) {
Py_BEGIN_ALLOW_THREADS
// Use 100ms timeout to periodically check whether the
// interpreter was interrupted
res = consumer.receive(msg, 100);
Py_END_ALLOW_THREADS
if (res != ResultTimeout) {
// In case of timeout we keep calling receive() to simulate a
// blocking call until a message is available, while breaking
// every once in a while to check the Python signal status
break;
}
if (PyErr_CheckSignals() == -1) {
PyErr_SetInterrupt();
return msg;
}
}
CHECK_RESULT(res);
return msg;
}
Message Consumer_receive_timeout(Consumer& consumer, int timeoutMs) {
Message msg;
Result res;
Py_BEGIN_ALLOW_THREADS
res = consumer.receive(msg, timeoutMs);
Py_END_ALLOW_THREADS
CHECK_RESULT(res);
return msg;
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services