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

Put watchdog loop behind __name__ == '__main__' #680

Merged
merged 1 commit into from
Sep 9, 2023

Conversation

BryceStevenWilley
Copy link
Contributor

I've been using some runtime-introspection tools (particularly stubtest) on docassemble's code base recently, and when you simply import watchdog, the tool will get stuck in an infinite loop because the only thing in the file is an infinite while: True loop.

This patch puts that behind if __name__ == '__main__', so only people who are running this module as the main module will get the desired infinite loop. The only documented way of running this module is through run-watchdog.sh, which runs python -m docassemble.webapp.watchdog &, so this shouldn't break any existing functionality.

Tested running in a built docker image, the watchdog process still is running after starting the container, so looks to be all good.

I've been running runtime-introspection tools (particularly stubtest) on
docassemble's code base recently, and when you simply `import watchdog`, the
tool will get stuck in an infinite loop because the only thing in the file is
an infinite `while: True` loop.

This patch puts that behind `if __name__ == '__main__'`, so only people who
are running this module as the main module will get the desired infinite loop.
The only documented way of running this module is through `run-watchdog.sh`,
which runs `python -m docassemble.webapp.watchdog &`, so this shouldn't break
any existing functionality.
@jhpyle jhpyle merged commit a14dd6d into jhpyle:master Sep 9, 2023
3 checks passed
@BryceStevenWilley BryceStevenWilley deleted the watchdog_main branch September 21, 2023 21:36
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