ynput / ayon-core

Apache License 2.0
31 stars 36 forks source link

Tray: Kill existing tray process #918

Closed iLLiCiTiT closed 1 week ago

iLLiCiTiT commented 1 month ago

Current Behavior:

If tray is force killed and machine is restarted, the file where tray PID is stored stays in local app data, so on next tray start it can try to kill completelly different process.

Expected Behavior:

It should be able to detect if the running process by PID is actually tray or something else.

Traceback

Traceback (most recent call last):
  File "C:\Users\...\AppData\Local\Ynput\AYON\addons\core_0.4.4\ayon_core\cli.py", line 331, in main
    main_cli(
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 1666, in invoke
    rv = super().invoke(ctx)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\...\AppData\Local\Ynput\AYON\addons\core_0.4.4\ayon_core\cli.py", line 59, in main_cli    ctx.forward(tray)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 804, in forward
    return __self.invoke(__cmd, *args, **kwargs)
  File "C:\Users\...\AppData\Local\Ynput\AYON\dependency_packages\ayon_2406251801_windows.zip\runtime\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\...\AppData\Local\Ynput\AYON\addons\core_0.4.4\ayon_core\cli.py", line 76, in tray
    main(force)
  File "C:\Users\...\AppData\Local\Ynput\AYON\addons\core_0.4.4\ayon_core\tools\tray\lib.py", line 618, in main
    _kill_tray_process(pid)
  File "C:\Users\...\AppData\Local\Ynput\AYON\addons\core_0.4.4\ayon_core\tools\tray\lib.py", line 87, in _kill_tray_process
    os.kill(pid, signal.SIGTERM)
OSError: [WinError 87] The parameter is incorrect
BigRoy commented 1 month ago

It seems I'm getting the same but with a slightly different stack trace:

!!! AYON crashed:
Traceback (most recent call last):
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\addons\core_0.4.5-cb.3\ayon_core\cli.py", line 313, in main
    main_cli(
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 1666, in invoke
    rv = super().invoke(ctx)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\addons\core_0.4.5-cb.3\ayon_core\cli.py", line 45, in main_cli
    ctx.forward(tray)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 804, in forward
    return __self.invoke(__cmd, *args, **kwargs)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\dependency_packages\ayon_2407291312_windows.zip\runtime\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\addons\core_0.4.5-cb.3\ayon_core\cli.py", line 62, in tray
    main(force)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\addons\core_0.4.5-cb.3\ayon_core\tools\tray\lib.py", line 618, in main
    _kill_tray_process(pid)
  File "C:\Users\Maqina-RTX-03\AppData\Local\Ynput\AYON\addons\core_0.4.5-cb.3\ayon_core\tools\tray\lib.py", line 87, in _kill_tray_process
    os.kill(pid, signal.SIGTERM)
PermissionError: [WinError 5] Access is denied

Workaround

This was my workaround, delete the file in:

%LOCALAPPDATA%\Ynput\AYON\tray

That file contains the pid that Tray thinks is still running. Then launch again.