From 2167ac117da85bce7d5841baba9dc8340c648d3d Mon Sep 17 00:00:00 2001 From: Dan Roozemond Date: Wed, 14 Sep 2022 15:48:37 +0200 Subject: [PATCH 1/5] add note in Settings on using WatchFiles on WSL --- docs/settings.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/settings.md b/docs/settings.md index 09a3db5d5..6a0ce54fe 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -38,8 +38,11 @@ If Uvicorn _cannot_ load [watchfiles](https://pypi.org/project/watchfiles/) at r ### Reloading with watchfiles -For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. This will enable the following options (which are otherwise ignored). +For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. +Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you have to set the environment variable `WATCHFILES_FORCE_POLLING` to `True`, otherwise reloading will silently fail. + +Using Uvicorn with watchfiles will enable the following options (which are otherwise ignored). * `--reload-include ` - Specify a glob pattern to match files or directories which will be watched. May be used multiple times. By default the following patterns are included: `*.py`. These defaults can be overwritten by including them in `--reload-exclude`. * `--reload-exclude ` - Specify a glob pattern to match files or directories which will excluded from watching. May be used multiple times. By default the following patterns are excluded: `.*, .py[cod], .sw.*, ~*`. These defaults can be overwritten by including them in `--reload-include`. From f8e6bfdbec5105651c71f9ad2f0f7d519b90b220 Mon Sep 17 00:00:00 2001 From: danroozemond <62466501+danroozemond@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:29:22 +0200 Subject: [PATCH 2/5] Update docs/settings.md Adopt suggested text change from PR#1647 Co-authored-by: Samuel Colvin --- docs/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/settings.md b/docs/settings.md index 6a0ce54fe..f3cd46685 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -40,7 +40,7 @@ If Uvicorn _cannot_ load [watchfiles](https://pypi.org/project/watchfiles/) at r For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. -Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you have to set the environment variable `WATCHFILES_FORCE_POLLING` to `True`, otherwise reloading will silently fail. +Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you might have to set the environment variable `WATCHFILES_FORCE_POLLING`, for file changes to trigger a reload. Using Uvicorn with watchfiles will enable the following options (which are otherwise ignored). * `--reload-include ` - Specify a glob pattern to match files or directories which will be watched. May be used multiple times. By default the following patterns are included: `*.py`. These defaults can be overwritten by including them in `--reload-exclude`. From 9ee912111a824b7b951e1b17ac73d1e85699c81f Mon Sep 17 00:00:00 2001 From: Dan Roozemond Date: Wed, 14 Sep 2022 16:30:45 +0200 Subject: [PATCH 3/5] add a link to watchfiles doc --- docs/settings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/settings.md b/docs/settings.md index f3cd46685..2d41dd00f 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -40,7 +40,7 @@ If Uvicorn _cannot_ load [watchfiles](https://pypi.org/project/watchfiles/) at r For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. -Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you might have to set the environment variable `WATCHFILES_FORCE_POLLING`, for file changes to trigger a reload. +Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you might have to set the environment variable `WATCHFILES_FORCE_POLLING`, for file changes to trigger a reload. See [watchfiles documentation](https://watchfiles.helpmanual.io/api/watch/) for further details. Using Uvicorn with watchfiles will enable the following options (which are otherwise ignored). * `--reload-include ` - Specify a glob pattern to match files or directories which will be watched. May be used multiple times. By default the following patterns are included: `*.py`. These defaults can be overwritten by including them in `--reload-exclude`. From 30c03d9f0ec2fb4268479049ba0f01bedc508e15 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 14 Sep 2022 17:59:38 +0200 Subject: [PATCH 4/5] Update docs/settings.md --- docs/settings.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/settings.md b/docs/settings.md index 2d41dd00f..95d71df5c 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -43,6 +43,7 @@ For more nuanced control over which file modifications trigger reloads, install Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you might have to set the environment variable `WATCHFILES_FORCE_POLLING`, for file changes to trigger a reload. See [watchfiles documentation](https://watchfiles.helpmanual.io/api/watch/) for further details. Using Uvicorn with watchfiles will enable the following options (which are otherwise ignored). + * `--reload-include ` - Specify a glob pattern to match files or directories which will be watched. May be used multiple times. By default the following patterns are included: `*.py`. These defaults can be overwritten by including them in `--reload-exclude`. * `--reload-exclude ` - Specify a glob pattern to match files or directories which will excluded from watching. May be used multiple times. By default the following patterns are excluded: `.*, .py[cod], .sw.*, ~*`. These defaults can be overwritten by including them in `--reload-include`. From e145e7886d565d0dd1d1e07001de64dd9fdbf0b8 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Wed, 14 Sep 2022 18:53:12 +0200 Subject: [PATCH 5/5] Use tip admonition for watchfiles env variable --- docs/settings.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index 95d71df5c..c40905f45 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -40,13 +40,16 @@ If Uvicorn _cannot_ load [watchfiles](https://pypi.org/project/watchfiles/) at r For more nuanced control over which file modifications trigger reloads, install `uvicorn[standard]`, which includes watchfiles as a dependency. Alternatively, install [watchfiles](https://pypi.org/project/watchfiles/) where Uvicorn can see it. -Note that if you use Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), for example when running a Docker container on Windows, you might have to set the environment variable `WATCHFILES_FORCE_POLLING`, for file changes to trigger a reload. See [watchfiles documentation](https://watchfiles.helpmanual.io/api/watch/) for further details. - Using Uvicorn with watchfiles will enable the following options (which are otherwise ignored). * `--reload-include ` - Specify a glob pattern to match files or directories which will be watched. May be used multiple times. By default the following patterns are included: `*.py`. These defaults can be overwritten by including them in `--reload-exclude`. * `--reload-exclude ` - Specify a glob pattern to match files or directories which will excluded from watching. May be used multiple times. By default the following patterns are excluded: `.*, .py[cod], .sw.*, ~*`. These defaults can be overwritten by including them in `--reload-include`. +!!! tip + When using Uvicorn through [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux), you might + have to set the `WATCHFILES_FORCE_POLLING` environment variable, for file changes to trigger a reload. + See [watchfiles documentation](https://watchfiles.helpmanual.io/api/watch/) for further details. + ## Production * `--workers ` - Use multiple worker processes. Defaults to the `$WEB_CONCURRENCY` environment variable if available, or 1.