Skip to content

Releases: quru/django-mediagenerator

Disable file watching when running tests

07 Dec 17:05
Compare
Choose a tag to compare

A problem arose in 1.12 when running Django tests with MEDIA_DEV_MODE = True (which isn't recommended but can be handy for debugging). The test runner seems to repeatedly initialise the middleware without freeing up old instances, resulting in exhaustion of resources from all the watchdog instances after a certain number of tests.

This version disables filesystem watching when tests are running, by looking out for a TESTING setting. To add this setting and have it applied automatically when you run manage.py test, add the following to your Django settings.py:

import sys
TESTING = 'test' in sys.argv

Faster performance in development mode

30 Nov 17:35
Compare
Choose a tag to compare

This fork adds a modified version of pull request #11 to v1.11 of the parent project, to fix performance problems when MEDIA_DEV_MODE is True.

Instead of walking the file system on every request, this version uses the Watchdog package to monitor the media directories, and only walks the file system again when a change is known to have been made.

In addition for COPY_MEDIA_FILETYPES (defaulting to images, icons, fonts), the file modification time is used as a hash instead of reading the file contents, also speeding up the file system walk.