ActivityWatch / aw-watcher-afk

Watches keyboard and mouse activity to determine if you are AFK or not (for use with ActivityWatch)
Mozilla Public License 2.0
47 stars 31 forks source link

make child and parent die together #24

Closed nikanar closed 7 years ago

nikanar commented 7 years ago

Same as https://github.com/ActivityWatch/aw-watcher-window/pull/20 for other watcher.

Aims to solve https://github.com/ActivityWatch/aw-qt/issues/19

Watcher process checks for being an orphan, and if it is, breaks.

Attempt at using branches, looking good, amazingly.

ErikBjare commented 7 years ago

The removed newlines should have been kept (PEP8 recommends 2 lines between top level functions and classes, so strict linters will complain).

Just one issue: This likely won't work with PyInstaller since it creates two Python processes afaik. One that's some kind of "bootloader" and the other which actually hosts the watcher (it's the bootloader that will be orphaned, not the watcher itself). This will lead to this not working in the PyInstaller case, but perhaps there is a way to detect PyInstaller and work around it.

Nice work regardless, this solution never occurred to me.

nikanar commented 7 years ago

@ErikBjare Let's discuss this PyInstaller problem in a new issue maybe ? First step would be to see what happens when aw-qt "crashes normally" under the PyInstaller bootloader - do the other processes still survive as in OP of #19 ? (so PyInstaller creates 2 instead of 1, but AW is 4, so how many total processes are we talking about here, 5 or 8 ? How is the PGID / process group thing set then ? etc.) I don't know how PyInstaller works, but I could imagine it only being the father of the aw-qt process, letting aw-qt father the others, and when aw-qt dies, maybe aw-server's PID becomes PyInstaller's instead of aw-qt's (then we would have to detect a change, rather than a 1 value).

Newlines : duly noted, my bad.

ErikBjare commented 7 years ago

I continued the discussion here: https://github.com/ActivityWatch/aw-qt/issues/19