gstd-1.x icon indicating copy to clipboard operation
gstd-1.x copied to clipboard

Is ping_gstd thread safe ?

Open MaxandreOgeret opened this issue 2 years ago • 1 comments

Hello, I would like to know if the python libgstc function is thread safe.

https://github.com/RidgeRun/gstd-1.x/blob/a011affa67f240cbc7aaff5b00fdfd6124bdaece/libgstc/python/pygstc/gstc.py#L258

I want to continuously ping the gstd server in an other thread. I had a look at the code and it seems that it is, as a new socket is created for each communication with gstd. But then can you guarantee that it will stay that way ?

Thanks.

MaxandreOgeret avatar Jan 24 '23 13:01 MaxandreOgeret

Hey @MaxandreOgeret sorry for the slow response. There are two things two consider:

  1. By default, the TCP server in Gstd is allowed to spawn as many threads as it needs. This means that, effectively, two requests may be taking place simultaneously. You may limit the number of simultaneous threads with the --tcp-max-threads option to 1, for example, and make sure all requests are serialized.
  2. On the other hand, the ping command internally just tries to list the available pipelines, which is a thread safe operation. The pipeline list is locked every time it is read or modified.

michaelgruner avatar Mar 21 '23 15:03 michaelgruner