-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataReader Listener Thread Safety #208
Comments
There is a lot here that I don't enough about (I don't know Python all that well) to give a definitive answer, but:
I would have expected your listener to have at least printed 10 lines, even if it'd then hang because of something in Cyclone: inside the listener you're not doing anything with Cyclone, so there's no reason you'd deadlock in Cyclone. That suggests to me that it is instead deadlocking on the GIL. I'd guess it has something to do with unlocking the GIL on I/O, but here I'm really in what (for me) are uncharted waters. If I am guessing right, then the only proper solution is to not call directly from the Cyclone core into a Python listener, but instead do it on a separate thread. Supporting calling application listeners on a separate thread also happens to be the solution to 1. There's even code floating around that kinda does that, e.g., https://github.com/eclipse-cyclonedds/cyclonedds/blob/master/src/tools/ddsperf/async_listener.c, but that's just a hack to solve a problem without having to solve the general case. I suppose it could be ported to the Python binding by someone who knows Python a lot better than I do. I would personally go for addressing 1, but I don't have the time for that right now, unfortunately. |
@eboasson Thanks for taking a look. It is unfortunate that Python+Listeners, in their current state, are unsuitable for usage in a concurrent writer scenario. I'll see what I can do with a WaitSet instead. |
The following code appears to trigger a deadlock when attempting to use a Listener on a DataReader.
I'm using CycloneDDS commit:
d38e63ff8ed5123650beab9bef2b294b56628696: 28 Jun 23
and CycloneDDS Python commit:
7486f5504a988efbd4838b8ecb881d20e34a7644: 25 May 23
and installing the Python library via
CYCLONEDDS_HOME=${CYCLONEDDS_HOME} python3 -m pip install /path/to/cyclonedds-python
Output:
Setting the DataReader listener to None resolves the deadlock. Is this an issue with the listener (or elsewhere), or am I doing something wrong here?
The text was updated successfully, but these errors were encountered: