BewareMyPower commented on code in PR #228:
URL:
https://github.com/apache/pulsar-client-python/pull/228#discussion_r1869272997
##########
src/consumer.cc:
##########
@@ -16,22 +16,39 @@
* specific language governing permissions and limitations
* under the License.
*/
+
#include "utils.h"
#include <pulsar/Consumer.h>
+#include <pulsar/ConsumerConfiguration.h>
+#include <pulsar/Result.h>
+#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
+#include <memory>
namespace py = pybind11;
void Consumer_unsubscribe(Consumer& consumer) {
waitForAsyncResult([&consumer](ResultCallback callback) {
consumer.unsubscribeAsync(callback); });
}
+void Consumer_unsubscribeAsync(Consumer& consumer, ResultCallback callback) {
+ consumer.unsubscribeAsync([callback] (Result result) {
+ py::gil_scoped_acquire acquire;
+ callback(result);
+ });
+}
+
Message Consumer_receive(Consumer& consumer) {
return waitForAsyncValue<Message>([&](ReceiveCallback callback) {
consumer.receiveAsync(callback); });
}
+void Consumer_receiveAsync(Consumer& consumer, ReceiveCallback callback) {
+ py::gil_scoped_acquire acquire;
Review Comment:
It should release the GIL rather than acquire the GIL
##########
src/consumer.cc:
##########
@@ -16,22 +16,39 @@
* specific language governing permissions and limitations
* under the License.
*/
+
#include "utils.h"
#include <pulsar/Consumer.h>
+#include <pulsar/ConsumerConfiguration.h>
+#include <pulsar/Result.h>
+#include <pybind11/functional.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
+#include <memory>
namespace py = pybind11;
void Consumer_unsubscribe(Consumer& consumer) {
waitForAsyncResult([&consumer](ResultCallback callback) {
consumer.unsubscribeAsync(callback); });
}
+void Consumer_unsubscribeAsync(Consumer& consumer, ResultCallback callback) {
+ consumer.unsubscribeAsync([callback] (Result result) {
+ py::gil_scoped_acquire acquire;
Review Comment:
This GIL acquire is not necessary
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]