enthought / traitsui

TraitsUI: Traits-capable windowing framework
http://docs.enthought.com/traitsui
Other
297 stars 96 forks source link

Multi_thread_demo_2.py hangs at exit #1743

Open mdickinson opened 3 years ago

mdickinson commented 3 years ago

The Multi_thread_demo_2.py demo script hangs at exit, when started from the command line.

Steps to reproduce (on macOS):

At this point, control doesn't return to the shell prompt until Ctrl-C is pressed, interrupting the Python process with a KeyboardInterrupt.

This might be a good place to show good practices in terms of keeping track of, and eventually joining, threads.

mdickinson commented 3 years ago

The example also shows potentially simultaneous updates to the self.counters list from multiple threads, which isn't ideal.

rahulporuri commented 3 years ago

I'm able to reproduce this behavior on windows with pyqt5

mdickinson commented 3 years ago

The other multithreading demo, https://github.com/enthought/traitsui/blob/7f246271c7fc54212d0e9609db65baf1d7f603b5/traitsui/examples/demo/Advanced/Multi_thread_demo.py, has similar issues. Threads are never joined, and there's a classic race condition in updating self.running.

rahulporuri commented 3 years ago

I think we should just consider removing both multi thread demo examples