Developing on a Windows (I know, please keep reading ) laptop, I find that
runserver’s auto reload functionality consumes quite a bit of power and thus battery. As well, while this is acutely detrimental to laptop battery life, for grid powered hardware this will result in extra load which ultimately comes from power generation - a process that in too many cases spews carbon into our atmosphere causing climate change.
It’s my understanding that this is truly not a problem with Django, but rather with how Windows handles watching. I as well understand that
WatchmanReloader, and projects like GitHub - adamchainz/django-watchfiles: Use watchfiles in Django’s autoreloader., may provide alternatives to
StatReloader. However, I’d like to suggest that the responsibility and known solutions don’t immediately address the needs of many of the users that will find themselves using
I believe that
runserver is most useful for novice developers who may lack the knowledge of Python, Django, and their OS, to explore an implement the known alternatives. Given this, I’d like to suggest that making it as simple as possible to reduce resource utilization for novice users is a worthwhile effort. To that end, I’d like to suggest that we add a command line parameter to
--sleeptime that will be passed to the implementation of
BaseReloader such that it may be used in place of any hard coded values, and in particular
StatReloader. Interestingly, while this is not a problem for
WatchmanReloader as that already looks for an environment variable
DJANGO_WATCHMAN_TIMEOUT, it might be helpful for
WatchmanReloader to take and use this param if supplied. Of course, it’d be an option to also load
SLEEP_TIME from an environment variable, but somehow that doesn’t seem like the djangonic way about this, and also doesn’t seem like the wildly beginner friendly solution that I’m suggesting with this post.
I can only imagine that a proposal to add a new parameter to
runserver might not be particularly welcome, but I hope that this suggestion will at least spark a conversation about how we might make
runserver a little bit less resource intensive.