Django 2.2.0 StatReloader not responding to filechanges

3,379 views
Skip to first unread message

in...@bobvoorneveld.nl

unread,
Apr 10, 2019, 8:05:31 AM4/10/19
to Django users
Since the introduction to Watchman, with the failover to StatReloader, the file changes aren't picked up.

We're running our Django development environment in Docker/Docker-compose, and 2.1.7 everything is still fine. But updating to 2.2.0, the file changes aren't picked up (or rarely).

We have installed Watchman in our docker, but then there was a timeout.

Any suggestions on how to fix watchman or make StatReloader work as it was in Django 2.1.7?

Logs:

[10/Apr/2019 12:39:13] INFO [django.utils.autoreload:578] Watching for file changes with WatchmanReloader
Performing system checks...

System check identified no issues (0 silenced).
April 10, 2019 - 12:39:16
Django version 2.2, using settings 'project.settings'
Starting ASGI/Channels version 2.1.7 development server at http://0:8000/
Quit the server with CONTROL-C.
[10/Apr/2019 12:39:16] INFO [daphne.server:111] HTTP/2 support not enabled (install the http2 and tls Twisted extras)
[10/Apr/2019 12:39:16] INFO [daphne.server:119] Configuring endpoint tcp:port=8000:interface=0
[10/Apr/2019 12:39:16] INFO [daphne.server:153] Listening on TCP address 0.0.0.0:8000
[10/Apr/2019 12:39:18] ERROR [django.utils.autoreload:569] Error connecting to Watchman: timed out waiting for response, while executing ('watch-project', '/home/docker/project')
[10/Apr/2019 12:39:18] INFO [django.utils.autoreload:570] Watching for file changes with StatReloader


This is our docker file for our web docker:

FROM python:3.7
ENV PYTHONUNBUFFERED 1

RUN apt-get update -y
RUN apt-get install -y \
binutils \
libproj-dev \
gdal-bin \
apt-utils \
gcc \
gettext \
sqlite3 \
python3-dev \
software-properties-common \
sudo \
--no-install-recommends && rm -rf /var/lib/apt/lists/*

ENV HOME /home/docker
RUN mkdir -p /home/docker/

WORKDIR $HOME
RUN git clone https://github.com/facebook/watchman.git
WORKDIR $HOME/watchman/
RUN git checkout v4.9.0
RUN ./autogen.sh
RUN ./configure
RUN make
RUN sudo make install

# USER docker
WORKDIR $HOME/project

RUN cd $HOME/project/

RUN sudo -H pip install -U pipenv==2018.10.9

COPY Pipfile $HOME/project/Pipfile
COPY Pipfile.lock $HOME/project/Pipfile.lock

RUN pipenv sync --dev


docker-compose.yml

version: '3.3'

services:
web:
build: .
command: pipenv run python manage.py runserver 0:8000
volumes:
- .:/home/docker/project
env_file:
- ".env"
ports:
- "8002:8000"
depends_on:
- postgres-db
networks:
- app-network

postgres-db:
image: kartoza/postgis
ports:
- "5433:5432"
env_file:
- ".env"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
- app-network

networks:
app-network:
driver: bridge


Pipfile

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
channels = "==2.1.7"
channels-redis = "==2.3.3"
daphne = "==2.2.5"
django = "==2.1.7"
django-redis = "==4.10.0"
gunicorn = "==19.9.0"
psycopg2-binary = "==2.8.1"

[requires]
python_version = "3.7"


ja...@workflowy.com

unread,
Apr 11, 2019, 5:52:27 PM4/11/19
to Django users
We have noticed the same thing. StatReloader is very unreliable (over docker) and Watchman timed out. I'm gonna try tweaking the Watchman config settings but it was the first time I have upgraded Django and had anything less than a perfectly smooth experience

ja...@workflowy.com

unread,
Apr 11, 2019, 6:34:27 PM4/11/19
to Django users
After more research, I noticed that Django is using the default timeout of 1sec for the pywatchman client. When I try running the watch with a higher timeout, I am able to start it successfully.

I would suggest that Django makes the timeout configurable, or chooses a higher default value.


On Wednesday, April 10, 2019 at 5:05:31 AM UTC-7, in...@bobvoorneveld.nl wrote:

ja...@workflowy.com

unread,
Apr 21, 2019, 6:57:59 PM4/21/19
to Django users
I submitted a bug report and am working on a patch:

https://code.djangoproject.com/ticket/30361

Also, it appears that some fixes to the StatReloader may be coming in 2.2.1 (or 2.3?) which could also help
Reply all
Reply to author
Forward
0 new messages