Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tray: Singleton tray #794

Merged
merged 35 commits into from
Jul 24, 2024
Merged

Conversation

iLLiCiTiT
Copy link
Member

Changelog Description

Tray is now singleton process. Only one tray can be running for AYON url and settings variant (production, staging or dev variants).

Additional info

Moved webserver module to tray tool and make it as base functionality of the tool. The webserver is also used to determine if tray is running or not. Tray is storing metadata file containing webserver url, pid and information if initialization finished which is used to determine if is already running.

Added some api functions to be able receive some of these information. The most important are is_tray_running and get_tray_server_url. The get_tray_server_url should be used instead of os.environ["AYON_WEBSERVER_URL"].

Notes

More features will come in future PRs, based on what we'll need.

Testing notes:

  1. Create ayon-core package and upload to AYON server.
  2. Use it in a bundle.
  3. Start tray.
  4. Try to start tray again, it should not start second one.

@ynbot
Copy link
Contributor

ynbot commented Jul 23, 2024

Task linked: AY-6113 Singleton tray with API

@ynbot ynbot added size/L type: feature Adding something new and exciting to the product labels Jul 23, 2024
@iLLiCiTiT iLLiCiTiT requested a review from BigRoy July 23, 2024 13:39
Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this seemed to work.

  1. I could not usually launch another tray to the same server
  2. I was able to launch a dev tray to my dev server, and simultaneously launch one for my production server (both in dev mode)

I did notice that if I run tray very rapidly after each other (e.g. run twice almost at the same time) it gets a bit further, doesn't close down but reaches this error (in console):

Traceback (most recent call last):
  File "E:\dev\ayon-core\client\ayon_core\tools\tray\ui\tray.py", line 625, in _on_start_timer
    self._tray_widget.initialize_addons()
  File "E:\dev\ayon-core\client\ayon_core\tools\tray\ui\tray.py", line 540, in initialize_addons
    self._tray_manager.initialize_addons()
  File "E:\dev\ayon-core\client\ayon_core\tools\tray\ui\tray.py", line 187, in initialize_addons
    set_tray_server_url(
  File "E:\dev\ayon-core\client\ayon_core\tools\tray\lib.py", line 182, in set_tray_server_url
    raise TrayIsRunningError("Tray is already running.")
ayon_core.tools.tray.lib.TrayIsRunningError: Tray is already running.

Aside of that it visually appears to "keep running" from the UI perspective.


Aside of me seeing from the console that it's shutting down because it already had a tray running I can imagine it's very easy to miss by an artist why it may fail to launch (if they even see that at all). As such, I wonder whether we should add a pop-up that says something like "Shutting down because another Tray process is already running") Or - maybe better yet, have it shut down but send a message to the running tray to show a "tray message/popup" with that message (so it brings to attention the one that is actively running with a tray message - and when the message is clicked (and not dismissed) opens the Launcher for example. So that for the artists running it again it doesn't look like nothing happens, instead they get focused at the one that is already running?

client/ayon_core/tools/tray/lib.py Outdated Show resolved Hide resolved
@iLLiCiTiT
Copy link
Member Author

I did notice that if I run tray very rapidly after each other (e.g. run twice almost at the same time) it gets a bit further, doesn't close down but reaches this error (in console):

Should be resolved now.

Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did notice that if I run tray very rapidly after each other (e.g. run twice almost at the same time) it gets a bit further, doesn't close down but reaches this error (in console):

Should be resolved now.

Correct, works now.


I still think this comment is valid:

Aside of me seeing from the console that it's shutting down because it already had a tray running I can imagine it's very easy to miss by an artist why it may fail to launch (if they even see that at all). As such, I wonder whether we should add a pop-up that says something like "Shutting down because another Tray process is already running") Or - maybe better yet, have it shut down but send a message to the running tray to show a "tray message/popup" with that message (so it brings to attention the one that is actively running with a tray message - and when the message is clicked (and not dismissed) opens the Launcher for example. So that for the artists running it again it doesn't look like nothing happens, instead they get focused at the one that is already running?

But we can leave that to a separate issue and PR.

@iLLiCiTiT
Copy link
Member Author

But we can leave that to a separate issue and PR.

100% agree, 100% different PR.

@iLLiCiTiT iLLiCiTiT merged commit d00676e into develop Jul 24, 2024
3 checks passed
@iLLiCiTiT iLLiCiTiT deleted the feature/AY-6113_Singleton-tray-with-API branch July 24, 2024 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L type: feature Adding something new and exciting to the product
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants