msancheznet / pyion

Interface between ION and Python
https://pyion.readthedocs.io/en/latest/index.html
Apache License 2.0
11 stars 9 forks source link

Python multithreading and pyion #10

Open msancheznet opened 1 year ago

msancheznet commented 1 year ago

pyion is designed to allow for operation in a multi-threaded environment. Internally, it makes sure to release the Python Global Interpreter Lock (GIL) prior to performing any operations that involve the SDR, which contains its own lock. By doing so, we ensure that there is no chance of having deadlocks between the GIL and the SDR.

However, testing has shown that it is still possible to cause unsafe race conditions when using pyion in a multi-threaded environment, and that this is likely caused by the ION public interface not being thread-safe. Therefore, even though this problem is not really part of pyion, we document it here for simplicity.

Finally, most experienced problems have occurred when using multiple threads to send data via endpoints. When separate threads are used for transmit and receive, then no race conditions have been observed.