snu-quiqcl / qiwis

QuIqcl Widget Integration Software
MIT License
5 stars 2 forks source link

Thread destroyed while running #99

Closed kangz12345 closed 1 year ago

kangz12345 commented 1 year ago

In my opinion, our problem situation is as follows:

  1. When terminating the program, Bus instances are destroyed without stopping the threads.
  2. When calling Swift.destroyBus(), since bus.stop() immediately returns and does not guarantee that the thread is stopped at all, the following bus.deleteLater() will be executed before the thread actually stops.

I cannot accept the proposed solution to add wait() as a slot of self._consumer.finished... I have no idea why it works. The reason is that self._consumer.finished is a signal that I defined, and it will never be emitted unless the stop() is called so the while loop in run() finishes.

However, I've found a very magical phenomenon. I tested as follows:

  1. Define a new signal QueueConsumer.test().
  2. Connect wait() as a slot to the test signal instead of finished signal.
  3. It also solves the problem! Note that I only defined the signal and never used it, i.e., test signal is never emitted.

😄 I will study this further...

Originally posted by @kangz12345 in https://github.com/snu-quiqcl/swift/pull/96#issuecomment-1474717462

kangz12345 commented 1 year ago

This is resolved (or has gone) by #112.