Skip to content

Conversation

@Tom-Willemsen
Copy link
Contributor

This PR contains some minimal changes to allow a FastCS driver to start on Windows.

  • loop.add_signal_handler() is not available on windows. On windows, signals are always delivered to the main thread of an application. Ctrl-c does correctly stop a FastCS driver in non-interactive mode on windows without this handler.
  • StdoutProxy didn't work on windows under pytest - I believe it is conflicting with pytest's stdout capturing. Just use sys.stdout for that case.

FastCS' own unit tests don't pass on Windows even with this change - that would require a larger PR.

@Tom-Willemsen Tom-Willemsen changed the title Windows: add guards for some methods that don't work/exist on win32 Windows: add guards for some methods that don't work/exist on windows Dec 19, 2025
@codecov
Copy link

codecov bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.84%. Comparing base (c86f760) to head (9ddca41).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #295      +/-   ##
==========================================
+ Coverage   90.82%   90.84%   +0.01%     
==========================================
  Files          70       70              
  Lines        2486     2490       +4     
==========================================
+ Hits         2258     2262       +4     
  Misses        228      228              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

is_pytest_on_windows = "PYTEST_VERSION" in os.environ and os.name == "nt"
logger.add(
sink=StdoutProxy(raw=True), # type: ignore
sink=sys.stdout if is_pytest_on_windows else StdoutProxy(raw=True), # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be moved to a fixture in the tests to keep the production code unchanged? I think something like this would do it

@pytest.fixture(scope="session", autouse=True)
def patch_stdoutproxy_on_windows(mocker: MockerFixture):
    if os.name == "nt":
        import fastcs.logging._logging as logging_mod

        mocker.patch.object(
            logging_mod,
            "StdoutProxy",
            return_value=sys.stdout,
        )

Copy link
Contributor Author

@Tom-Willemsen Tom-Willemsen Dec 19, 2025

Choose a reason for hiding this comment

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

I think the issues with this are:

  • Currently this code path is hit when tests are being collected (i.e. before any fixtures get to run) as it's done at import time. An adapted version does work in a pytest_sessionstart hook, but that seems a bit messy to me.
  • This would be needed in every downstream repo that tests on windows - I guess we could export a function that does this from FastCS for use by downstream tests in their pytest_sessionstart hook?

Let me know what you prefer?

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.

2 participants