Skip to content

Fix non-Windows UI startup checks#1475

Open
biefan wants to merge 3 commits intoAzure:mainfrom
biefan:fix-non-windows-ui-startup
Open

Fix non-Windows UI startup checks#1475
biefan wants to merge 3 commits intoAzure:mainfrom
biefan:fix-non-windows-ui-startup

Conversation

@biefan
Copy link
Contributor

@biefan biefan commented Mar 16, 2026

Summary

This fixes the deprecated Gradio UI startup path on non-Windows platforms.

Problem

pyrit.ui.app currently treats the Windows mutex logic as mandatory in two places:

  • is_app_running() raises NotImplementedError on non-Windows platforms
  • the __main__ startup path defines a nested create_mutex() helper that also raises NotImplementedError on non-Windows platforms

That creates two failure modes on Linux/macOS:

  1. AppRPCServer.start() calls is_app_running() before launching the UI, so the RPC path fails during the probe step.
  2. Even if the process is launched directly, the child process fails immediately in the __main__ block before it can start the Gradio app.

Fix

  • move create_mutex() to module scope so the startup guard is reusable and testable
  • make create_mutex() a no-op that returns True on non-Windows platforms
  • make is_app_running() return False on non-Windows platforms instead of raising

This preserves the existing Windows mutex-based single-instance behavior while allowing non-Windows platforms to proceed through the UI startup path.

Tests

Added unit coverage for the non-Windows behavior:

  • is_app_running() returns False
  • create_mutex() returns True

Validation command:

uv run --extra dev pytest tests/unit/ui/test_app.py -q

Validation result:

2 passed, 1 warning in 0.04s

The warning is the existing deprecation warning for pyrit.ui.

Copy link
Contributor

@rlundeen2 rlundeen2 left a comment

Choose a reason for hiding this comment

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

This looks good, but we're deprecating all of this very soon, it probably should already be deprecated. The new frontend is in /frontend.

I don't see a downside to merging this sooner vs later though

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the deprecated pyrit.ui startup path so that non-Windows platforms (Linux/macOS) no longer error out during the “is UI already running?” probe or the __main__ startup guard, while preserving the existing Windows single-instance mutex behavior.

Changes:

  • Introduces a reusable module-scope create_mutex() helper and uses it in __main__.
  • Makes create_mutex() a no-op returning True on non-Windows platforms.
  • Makes is_app_running() return False on non-Windows platforms instead of raising, and adds unit tests for these behaviors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pyrit/ui/app.py Moves mutex creation to module scope and makes both mutex creation and “already running” checks non-fatal on non-Windows.
tests/unit/ui/test_app.py Adds unit tests asserting non-Windows behavior for is_app_running() and create_mutex().

You can also share your feedback on Copilot code review. Take the survey.

rlundeen2 and others added 2 commits March 16, 2026 13:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants