Unsubscribing from events in the event callback
|
|
---|---|
Dear Tango Experts! I have a question reagarding events. In my setup I have a device server (DS1) which exports a device (Dev1) with two attributes (Attr1 and Attr2). In the client I subscribe to the events of Attr1 and Attr2. I would like to unsubscribe from Attr2 events when I receive a specific event from Attr1. I have tried to do it directly in the Attr1 event callback (call unsubscribe_event with id of Attr2 subscription) but it ends with a deadlock. Is it a normal behavior? Thanks for your explanation! |
|
|
---|---|
Hi Zibi, I have made a small C++ client which is doing what you describe. I don't have problem. I attach this small client to this post. Is it what you try to do? Cheers Emmmanuel |
|
|
---|---|
Hi Manu, Thanks for your your answer and the example. The example is exactly what I want to do, with a small difference that the event type is CHANGE. But I think it does not matter. I have already done some tests with your client and TangoTest. I do not have clear conclussions, my results are very strange: Test 1
Test 2
Test 3
Test 4
Today I leave on 3 weeks holidays, so I won't be able to reply regularly on this thread, sorry.. Thanks again, Zibi |
|
|
---|---|
Hello again, I have continued with the tests. Below some more results: Test 5
Test 6
After the first 4 tests I was thinking that maybe it could be related to the configuration where all: DataBaseds, TangoTest and the client run on the same PC. But in the Test 6, using full setup of Tango 9.1.0, there are no problem. Do you think that it could be related to this specific configuration but using the Tango 8.1.2? Do you want me to do some other tests or provide more information? Thanks a lot! Zibi |
|
|
---|---|
Hi, I attach backtraces of all the 6 threads of the client process (when the event callback deadlocks on the unsubscribe_event call) from the Test 1. Cheers, Zibi |
|
|
---|---|
Hi Zibi, The stack traces are interesting. I will look into this and keep you informed. But I thought you are in holidays. In my case, it is this evening until the 5 of January. Wonderful! But no snow in Grenoble! Cheers Manu |
|
|
---|---|
Hi Zibi, First the classical sentence these days: Happy new year to you and to everybody at ALBA. From your tests, it seems that Tango 9.1 solves your problem because it works fine for your tests 5 and 6. I checked into the code repository and effectively there is a change in this part of code between Tango 8 and 9. I completely forgot this change and it is not documented in the TANGO_CHANGES file! The code I am referring to is about un-subscription in event callback and more precisely about the detection that the unsubscribe call is done in the callback. When this works fine, the real un-subscription is done by a thread spawn by Tango to avoid the deadlock. In the stack traces you provided, this thread is not there meaning that the detection of event un-subscription during the callback failed. I don't think this could happen with the code used in Tango 9. Do you confirm that using Tango 9 you are not able to re-produce the problem? Cheers Emmanuel |
|
|
---|---|
Hello Manu, Happy New Year to you too! I had also spent "strange" Christmans in Poland, with +10 degrees! Thanks for looking into this problem. I confirm that in Tango 9 everything works well. I think your suspicions are right. I have copied the solution from Tango 9 into the Tango 8, and the deadlock disappeared. I think it could be interesting to make a public patch for that (we want to base on that some solutions in Sardana..), what is your opinion? I attach here the changes that solved the problem for me (I was not very creative, just copied the necessary code from the Tango 9). I'm not sure, but I think that the notifd event consumer should also initialize the thread_id. If you agree, I could add this change as well and prepare a new patch. Cheers, Zibi |