[Question] How to follow symbolic link
I found that it does not follow the symbolic link, how to make it follow sym-link?
My guess is this occurs because the a symbolic link is considered a file, even if it points to a directory. You could solve this by iterating through your watched folders and adding new watches to each symbolic link pointing to a directory. If there's demand for this, I might be able to add an option to make symbolic links pointing to directories enabled through an optional parameter.
A simple solution is to apply os.path.realpath on all watched folders. So, we end up with something like:
observer.schedule(event_handler, os.path.realpath(path))
It could be by default in the library. Eventually with a verification that the simlink, if it is one, is not broken.
You do not specify platform. I implemented a fix for Linux on my branch... see if it helps: https://github.com/petersilva/watchdog
A regular directory I have here contains several symbolic links, each of which points to a file that lives elsewhere. When the content of any such file changes, I want to be alerted. That does not happen out of the box and I do not see how to make it happen via watchdog.
I'm under Linux. In a somewhat desperate attempt, I removed a symbolic link and replace it with a single-file-mount, something like touch file && sudo mount --bind ../otherdir/file file, as a workaround. But even that did not work.
I found that this works for my case:
from watchdog.observers.polling import PollingObserver as Observer
Not much later: A brief test suggests that this also works in the "symlink to directory" case.