darxtrix / ptop

An awesome task manager written in python. :computer:
http://darxtrix.in/ptop/
MIT License
576 stars 43 forks source link

Kill ptop properly #26

Open darxtrix opened 7 years ago

darxtrix commented 7 years ago

Observation 1:

In case any exception occurs, an exception should be logged properly and ptop should be killed properly will all of the threads ( gui and sensor threads ) killed properly. For eg. in case, the GUI cannot be drawn properly exception occurs and ptop hangs.

Observation 2:

While killing ptop, catch the kill signals properly and kill all the threads.

vinusankarsiitgn commented 6 years ago

Just add the following code to quit() my_pid = os.getpid() target = psutil.Process(int(my_pid)) try: target.terminate() except: self._logger.info("Operation failed", exc_info=True)

The issue was because quit only raised a keyboard interrupt, but not killed the process itself.

darxtrix commented 6 years ago

Thanks for the suggestions. I primarily made the issues for keeping a track of things and get some contributions going. A bit busy nowadays, will start on things when i will get some bandwidth.

darxtrix commented 6 years ago

@vinusankarsiitgn I checked the pr, let me be affirmative on that. Thanks !

darxtrix commented 6 years ago

The real problem is that the exceptions in child thread are not getting caught in the main thread of the application. We need to either set the global threading.Event at all the places where exceptions can occur in threads or we need to use some kind of message passing.