{"action":"created","issue":{"url":"https://api.github.com/repos/django/django/issues/8819","repository_url":"https://api.github.com/repos/django/django","labels_url":"https://api.github.com/repos/django/django/issues/8819/labels{/name}","comments_url":"https://api.github.com/repos/django/django/issues/8819/comments","events_url":"https://api.github.com/repos/django/django/issues/8819/events","html_url":"https://github.com/django/django/pull/8819","id":246155699,"number":8819,"title":"Refs #27685 -- Refactor the autoreloader","user":{"login":"orf","id":1027207,"avatar_url":"https://avatars1.githubusercontent.com/u/1027207?v=4","gravatar_id":"","url":"https://api.github.com/users/orf","html_url":"https://github.com/orf","followers_url":"https://api.github.com/users/orf/followers","following_url":"https://api.github.com/users/orf/following{/other_user}","gists_url":"https://api.github.com/users/orf/gists{/gist_id}","starred_url":"https://api.github.com/users/orf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orf/subscriptions","organizations_url":"https://api.github.com/users/orf/orgs","repos_url":"https://api.github.com/users/orf/repos","events_url":"https://api.github.com/users/orf/events{/privacy}","received_events_url":"https://api.github.com/users/orf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-07-27T20:13:50Z","updated_at":"2017-08-21T05:59:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/django/django/pulls/8819","html_url":"https://github.com/django/django/pull/8819","diff_url":"https://github.com/django/django/pull/8819.diff","patch_url":"https://github.com/django/django/pull/8819.patch"},"body":"[Ticket](https://code.djangoproject.com/ticket/27685)\r\n\r\nThe ticket is about adding support for watchman to the autoreloader, but a lot of Aymeric's points rang true - especially about a complete rewrite rather than a bit-by-bit refactor. There are a few other related tickets to do with the autoreloader that would require some re-engineering before they could be got right.\r\n\r\nThis MR does a big cleanup of the autoreloader code, which ends up to be half the size, be (i hope) a lot less hairy and have some interesting features. \r\n\r\nFirstly, it implements two signals (`autoreload_started` and `file_changed`) that allow other parts of Django and perhaps even third party apps to customize what files are watched and offer custom handing when a file is changed. This is used to implement the `i18n` translations reset code, which currently lives in the autoreload code (and IMO really should not). Users of the signal are given the auto-reload instance which has a `watch` method, which accepts a `glob` argument, e.g:\r\n\r\n`autoreloader.watch('some_directory/', '**/*.html')`\r\n\r\nSecondly the autoreload code is split into two classes, a `BaseReloader` and a concrete `StatReloader`. In the future this can be used to add support for watchman or any other algorithm for detecting changes - it just needs to implement a `yield_changes` function that yields the paths of files that have changed.\r\n\r\nIt also changes the behaviour slightly: the current implementation replaces `.pyc` files with `.py`, but I'm not sure this is still valid. It assumes that `.py` files live next to `.pyc` files, which in Python 3 and `__pycache__` directories may not be true. So I removed the code that handled that, as well as Jython-specific stuff.\r\n\r\nIt doesn't currently include support for catching SyntaxErrors, which I kept out in case anyone had a good idea of how to do a clean implementation of it. The current code (to quote Aymeric) is 'horrific'. It also doesn't include the `ensure_echo_on` code, which was a ticket that was added a long time ago. It has no tests and perhaps it's not required any more?"},"comment":{"url":"https://api.github.com/repos/django/django/issues/comments/323653286","html_url":"https://github.com/django/django/pull/8819#issuecomment-323653286","issue_url":"https://api.github.com/repos/django/django/issues/8819","id":323653286,"user":{"login":"aaugustin","id":788910,"avatar_url":"https://avatars1.githubusercontent.com/u/788910?v=4","gravatar_id":"","url":"https://api.github.com/users/aaugustin","html_url":"https://github.com/aaugustin","followers_url":"https://api.github.com/users/aaugustin/followers","following_url":"https://api.github.com/users/aaugustin/following{/other_user}","gists_url":"https://api.github.com/users/aaugustin/gists{/gist_id}","starred_url":"https://api.github.com/users/aaugustin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aaugustin/subscriptions","organizations_url":"https://api.github.com/users/aaugustin/orgs","repos_url":"https://api.github.com/users/aaugustin/repos","events_url":"https://api.github.com/users/aaugustin/events{/privacy}","received_events_url":"https://api.github.com/users/aaugustin/received_events","type":"User","site_admin":false},"created_at":"2017-08-21T05:59:52Z","updated_at":"2017-08-21T05:59:52Z","body":"Yes, why not. Check the behavior before / after in the following cases: run manage.py runserver:\r\n\r\n- with an error in the settings, then remove that error\r\n- with an error in another module then remove that error\r\n- without errors, then add an error in the settings, then remove that error\r\n- without errors, then add an error in another file, then remove that error\r\n\r\nBTW I just remembered the reason for watching the whole current directory rather just imported Python modules: that will catch file additions like admin.py."}}
{"actor":{"display_login":"aaugustin"}}