merlimat commented on issue #84:
URL: 
https://github.com/apache/pulsar-client-python/issues/84#issuecomment-1412374679

   @zbentley 
   
   > can you expand on It's only the sendAsync that is impacted?
   
   In this Python wrapper we mostly expose sync methods, eg: 
`client.create_produce()`, etc.. The only async method is 
`producer.send_async()`. 
   
   For sync methods, we internally use the C++ async version (to avoid blocking 
when checking for Python interruptions) and handle the GIL properly. We have a 
function for that purpose: 
https://github.com/apache/pulsar-client-python/blob/main/src/utils.h#L60-L87
   
   
   > Unless something is handling grabbing the GIL when the callback is 
triggered, it seems like that PR may resolve the deadlock at the expense of 
making the python interactions non-thread-safe.
   
   You can see in the stack trace above that PyBind is already automatically 
acquiring the GIL when triggering the Python callback :
   
   ```
   thread #2
       frame #0: 0x00007ff80a1943ea libsystem_kernel.dylib`__psynch_cvwait + 10
       frame #1: 0x00007ff80a1cea6f libsystem_pthread.dylib`_pthread_cond_wait 
+ 1249
       frame #2: 0x0000000105a3cb9f python3.7`take_gil + 255
       frame #3: 0x0000000105a3cfb3 python3.7`PyEval_AcquireThread + 19
       frame #4: 0x000000010870be43 
_pulsar.cpython-37m-darwin.so`pybind11::gil_scoped_acquire::gil_scoped_acquire()
 + 83
       frame #5: 0x00000001087714f3 
_pulsar.cpython-37m-darwin.so`pybind11::detail::type_caster<std::__1::function<void
 (pulsar::Result, pulsar::MessageId const&)>, void>::load(pybind11::handle, 
bool)::func_handle::func_handle(func_handle const&) + 35
       frame #6: 0x00000001087715f1 
_pulsar.cpython-37m-darwin.so`std::__1::__function::__func<pybind11::detail::type_caster<std::__1::function<void
 (pulsar::Result, pulsar::MessageId const&)>, void>::load(pybind11::handle, 
bool)::func_wrapper, 
std::__1::allocator<pybind11::detail::type_caster<std::__1::function<void 
(pulsar::Result, pulsar::MessageId const&)>, void>::load(pybind11::handle, 
bool)::func_wrapper>, void (pulsar::Result, pulsar::MessageId 
const&)>::__clone() const + 49
       frame #7: 0x00000001088daccd 
_pulsar.cpython-37m-darwin.so`std::__1::__function::__func<pulsar::ProducerImpl::sendAsync(pulsar::Message
 const&, std::__1::function<void (pulsar::Result, pulsar::MessageId 
const&)>)::$_2, 
std::__1::allocator<pulsar::ProducerImpl::sendAsync(pulsar::Message const&, 
std::__1::function<void (pulsar::Result, pulsar::MessageId const&)>)::$_2>, 
void (pulsar::Result, pulsar::MessageId const&)>::__clone() const + 93
       frame #8: 0x000000010878f7de 
_pulsar.cpython-37m-darwin.so`pulsar::OpSendMsg::OpSendMsg(pulsar::OpSendMsg 
const&) + 126
   
   ```


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