Skip to content

Commit

Permalink
[FIX] core: --dev=reload with watchdog==4.0.0
Browse files Browse the repository at this point in the history
If you're on Linux, make sure `inotify` is uninstalled:

	pip uninstall inotify

Install `watchdog` to its latest release, 4.0.0, and start odoo in
dev-reload mode. This mode restart the application everytime a file is
modified in one of the addons.

	pip install watchdog==4.0.0 -U
	odoo-bin ... --dev=reload  # replace ... with your arguments

Modify a file, save it. The server doesn't reload while it should.

Before gorakhargosh/watchdog@41fca1eb, only the `FileSystemMovedEvent`
class had a `dest_path` attribute (actually a property). In our code, we
used a `getattr` approach to fallback on `src_path` (which is set on all
three event classes) in case `dest_path` was not set.

Since that commit, the attribute has been moved to the base abstract
class `FileSystemEvent` which all three `FileCreatedEvent`,
`FileModifiedEvent`, and `FileMovedEvent` inherit. Hence the attribute
is always set (sometime to an empty string) and the getattr must be
adapted.

The new code supports both watchdog==3.0.0 and watchdog==4.0.0.

closes odoo#159045

X-original-commit: 9dd4418
Signed-off-by: Julien Castiaux (juc) <[email protected]>
  • Loading branch information
shenhuiqi authored and Julien00859 committed Mar 26, 2024
1 parent a9a9d2f commit b7532d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doc/cla/individual/shenhuiqi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
China, 2024-3-15

I hereby agree to the terms of the Odoo Individual Contributor License
Agreement v1.0.

I declare that I am authorized and able to make this agreement and sign this
declaration.

Signed,

HuiQi Shen [email protected] https://github.com/shenhuiqi
2 changes: 1 addition & 1 deletion odoo/service/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def __init__(self):
def dispatch(self, event):
if isinstance(event, (FileCreatedEvent, FileModifiedEvent, FileMovedEvent)):
if not event.is_directory:
path = getattr(event, 'dest_path', event.src_path)
path = getattr(event, 'dest_path', '') or event.src_path
self.handle_file(path)

def start(self):
Expand Down

0 comments on commit b7532d3

Please sign in to comment.