OK, yet again...
It seems that all the done functions with the exception of device_detected are called from the GUI thread. I am not sure how this comes to be, but it is. FunctionDispatcher would lock up in that case, because one thread is to put the request and another thread consume it. If both are the same thread, then the consumer never gets a chance.
Using Dispatcher in this case works, but given that the threads are the same the call to the done function will happen *after* everything else that goes on, including signal catching and the like. This is wrong.
I have pushed changes where FunctionDispatcher checks if the calling and called thread are the same, and if so directly calls done without signals or queues. I traced it with print statements and it did the right thing when the threads were and were not the same. I also tested it (again) multiple times with my sony and got the behavior I expected.
I think it is stable. I suggest that you merge my branch back in and let meme have at it. If it doesn't fix his problems, then back it out (again) and we will need to do more work to see why he is being called out of turn.
|