watchfiles: M1 mac with Docker WatchfilesRustInternalError: Error creating watcher: Function not implemented (os error 38)

Description

When starting django with the watcher (after installing from pypi from the wheel)

PostgreSQL is available
INFO:     Will watch for changes in these directories: ['/app']
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [18] using WatchFiles
Traceback (most recent call last):
  File "/usr/local/bin/uvicorn", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
=== Starting migration
Operations to perform:
  Apply all migrations: account, address, admin, auth, contenttypes, customers, orders_tenant, permissions, sessions, socialaccount, users
Running migrations:
  No migrations to apply.
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/uvicorn/main.py", line 407, in main
    run(
  File "/usr/local/lib/python3.9/site-packages/uvicorn/main.py", line 570, in run
    ChangeReload(config, target=server.run, sockets=[sock]).run()
  File "/usr/local/lib/python3.9/site-packages/uvicorn/supervisors/basereload.py", line 45, in run
    for changes in self:
  File "/usr/local/lib/python3.9/site-packages/uvicorn/supervisors/basereload.py", line 64, in __next__
    return self.should_restart()
  File "/usr/local/lib/python3.9/site-packages/uvicorn/supervisors/watchfilesreload.py", line 85, in should_restart
    changes = next(self.watcher)
  File "/usr/local/lib/python3.9/site-packages/watchfiles/main.py", line 103, in watch
    watcher = RustNotify([str(p) for p in paths], debug, force_polling, poll_delay_ms)
_rust_notify.WatchfilesRustInternalError: Error creating watcher: Function not implemented (os error 38)

Example Code

No response

Example Code Output

No response

Operating System

Mac M1 12.3.1 (21E258)

Environment

Docker

Watchfiles Version

0.15.0

Python Version

3.9

Rust & Cargo Version

cargo: not found; rustc: not found

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Great, thank you for confirming. I’ll make a new release tomorrow.

Okay, this is fixed in #172.

Please could those experiencing this problem @daniel-butler @br3ndonland @gravy-jones-locker try this and confirm it fixes the problem for you.

To install from wheel from the PR:

  • Download pypi_files from the CI run
  • Extract the zip
  • pip install pypi_files/watchfiles-0.0.0-cp37-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl

missed the notifications for these. but the immediate issue is definitely fixed. thanks!

It is working for me when I use the updated wheel! Thank you for fixing!

PostgreSQL is available
=== Starting migration
Operations to perform:
  Apply all migrations: account, address, admin, auth, contenttypes, customers, orders_tenant, permissions, sessions, socialaccount, users
Running migrations:
  No migrations to apply.
INFO:     Will watch for changes in these directories: ['/app']
INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [18] using WatchFiles
INFO:     Started server process [24]
INFO 2022-07-20 10:56:05,658 server 24 274910471360 Started server process [24]
INFO:     Waiting for application startup.
INFO 2022-07-20 10:56:05,662 on 24 274910471360 Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO 2022-07-20 10:56:05,664 on 24 274910471360 ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO 2022-07-20 10:56:05,665 on 24 274910471360 Application startup complete.
INFO:     172.18.0.1:64966 - "GET /hub/work/order/ HTTP/1.1" 200 OK
INFO:     172.18.0.1:64974 - "GET /static/debug_toolbar/css/toolbar.css HTTP/1.1" 200 OK
INFO:     172.18.0.1:64972 - "GET /static/css/project.min.css HTTP/1.1" 200 OK
INFO:     172.18.0.1:64976 - "GET /static/debug_toolbar/js/toolbar.js HTTP/1.1" 200 OK
INFO:     172.18.0.1:64972 - "GET /static/debug_toolbar/css/print.css HTTP/1.1" 200 OK
INFO:     172.18.0.1:64972 - "GET /static/debug_toolbar/js/utils.js HTTP/1.1" 200 OK
INFO:     172.18.0.1:64988 - "GET /hub/work/home/ HTTP/1.1" 200 OK
INFO:     172.18.0.1:64992 - "GET /static/css/project.min.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:64994 - "GET /static/debug_toolbar/js/toolbar.js HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:64996 - "GET /static/debug_toolbar/css/toolbar.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:64994 - "GET /static/debug_toolbar/css/print.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:64992 - "GET /static/debug_toolbar/js/utils.js HTTP/1.1" 304 Not Modified
INFO 2022-07-20 11:00:44,302 workhub 24 275185379072 form_action = /hub/work/task-work/2/
INFO:     172.18.0.1:65008 - "GET /hub/work/task-work/2/ HTTP/1.1" 200 OK
INFO:     172.18.0.1:65014 - "GET /static/debug_toolbar/css/toolbar.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65016 - "GET /static/debug_toolbar/js/toolbar.js HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65012 - "GET /static/css/project.min.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65014 - "GET /static/debug_toolbar/js/utils.js HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65016 - "GET /static/debug_toolbar/css/print.css HTTP/1.1" 304 Not Modified
WARNING:  WatchFiles detected changes in 'listing_service/orders_tenant/models.py'. Reloading...
INFO:     Shutting down
INFO 2022-07-20 11:01:38,647 server 24 274910471360 Shutting down
INFO:     Finished server process [24]
INFO 2022-07-20 11:01:38,749 server 24 274910471360 Finished server process [24]
INFO:     Started server process [49]
INFO 2022-07-20 11:01:48,922 server 49 274910471360 Started server process [49]
INFO:     Waiting for application startup.
INFO 2022-07-20 11:01:48,926 on 49 274910471360 Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO 2022-07-20 11:01:48,929 on 49 274910471360 ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO 2022-07-20 11:01:48,930 on 49 274910471360 Application startup complete.
INFO 2022-07-20 11:01:51,662 workhub 49 275016066816 form_action = /hub/work/task-work/2/
INFO:     172.18.0.1:65038 - "GET /hub/work/task-work/2/ HTTP/1.1" 200 OK
INFO:     172.18.0.1:65042 - "GET /static/debug_toolbar/css/toolbar.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65046 - "GET /static/debug_toolbar/js/toolbar.js HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65044 - "GET /static/css/project.min.css HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65042 - "GET /static/debug_toolbar/js/utils.js HTTP/1.1" 304 Not Modified
INFO:     172.18.0.1:65046 - "GET /static/debug_toolbar/css/print.css HTTP/1.1" 304 Not Modified
WARNING:  WatchFiles detected changes in 'listing_service/orders_tenant/models.py'. Reloading...
INFO:     Shutting down
INFO 2022-07-20 11:02:02,787 server 49 274910471360 Shutting down
INFO:     Finished server process [49]
INFO 2022-07-20 11:02:02,889 server 49 274910471360 Finished server process [49]
INFO:     Started server process [61]
INFO 2022-07-20 11:02:13,613 server 61 274910471360 Started server process [61]
INFO:     Waiting for application startup.
INFO 2022-07-20 11:02:13,616 on 61 274910471360 Waiting for application startup.
INFO:     ASGI 'lifespan' protocol appears unsupported.
INFO 2022-07-20 11:02:13,619 on 61 274910471360 ASGI 'lifespan' protocol appears unsupported.
INFO:     Application startup complete.
INFO 2022-07-20 11:02:13,621 on 61 274910471360 Application startup complete.

Okay, I can reproduce this.

First the good news:

  1. I don’t get this error (and watchfiles seems to correctly detect changes) if I remove --platform linux/amd64
  2. Same if I use force_polling=True
  3. As per the traceback, watchfiles is catching this error, so we should be able to catch the error and gracefully fall back to polling

It might also be worth honouring an env variable to enable polling for those who are using watchfiles via a third party library and therefore aren’t able to use the kwarg directly.

In terms of the underlying error and how to handle it, I’m not really sure where to go.

@messense do you have any ideas?