BewareMyPower commented on code in PR #228:
URL: 
https://github.com/apache/pulsar-client-python/pull/228#discussion_r1827282524


##########
src/consumer.cc:
##########
@@ -4,7 +4,7 @@
  * distributed with this work for additional information
  * regarding copyright ownership.  The ASF licenses this file
  * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance

Review Comment:
   Could you revert this change?



##########
develop/install_manifest.txt:
##########
@@ -0,0 +1 @@
+/home/nl/PycharmProjects/pulsar-client-python/lib_pulsar.so

Review Comment:
   Could you remove these two TXT files?



##########
src/client.cc:
##########
@@ -41,19 +42,39 @@ Consumer Client_subscribe(Client& client, const 
std::string& topic, const std::s
         [&](SubscribeCallback callback) { client.subscribeAsync(topic, 
subscriptionName, conf, callback); });
 }
 
+void Client_subscribeAsync(Client& client, const std::string& topic, const 
std::string& subscriptionName,
+                          const ConsumerConfiguration& conf, SubscribeCallback 
callback) {
+    py::gil_scoped_release release;
+    client.subscribeAsync(topic, subscriptionName, conf, callback);
+}
+
 Consumer Client_subscribe_topics(Client& client, const 
std::vector<std::string>& topics,
                                  const std::string& subscriptionName, const 
ConsumerConfiguration& conf) {
     return waitForAsyncValue<Consumer>(
         [&](SubscribeCallback callback) { client.subscribeAsync(topics, 
subscriptionName, conf, callback); });
 }
 
+void Client_subscribe_topicsAsync(Client& client, const 
std::vector<std::string>& topics, const std::string& subscriptionName, const 
ConsumerConfiguration& conf, SubscribeCallback callback){
+    client.subscribeAsync(topics, subscriptionName, conf, [callback](Result 
result, pulsar::Consumer consumer){

Review Comment:
   pybind11 will acquire the GIL when the wrapped callback of Python function 
is called. See 
https://pybind11.readthedocs.io/en/stable/advanced/misc.html#global-interpreter-lock-gil
   
   > pybind11 will ensure that the GIL is held when it knows that it is calling 
Python code. For example, if a Python callback is passed to C++ code via 
std::function, when C++ code calls the function the built-in wrapper will 
acquire the GIL before calling the Python callback.
   
   So you don't need to wrap the callback again with  `py::gil_scoped_acquire`



-- 
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]

Reply via email to