You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "tsturzl (via GitHub)" <gi...@apache.org> on 2023/10/12 16:05:39 UTC

Re: [I] Python3 AsyncIO implementation [pulsar-client-python]

tsturzl commented on issue #55:
URL: https://github.com/apache/pulsar-client-python/issues/55#issuecomment-1759925342

   @zbentley Integrating this client with asyncio is incredibly frustrating, because it's not entirely clear which thread things are running in and much of asyncio is **not threadsafe**. In order to get these callbacks to work with asyncio you have to resort to low level threadsafe facilities of asyncio, making it far less trivial to safely integrate this client with asyncio than you portray.
   
   For example if you want to use `send_async`. Intuition might lead you to just pass a future into that callback, and set the result of that future when you're done. You cannot do that, because Future is not threadsafe. You instead need to call `future.set_result` using `loop.call_soon_threadsafe(future.set_result, res)`.


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org