'Watchdog fails to catch file modification while the file is opened by another program

I'm trying to use watchdog to monitor a specific log file of a program. However, on_modified is called only when that program initiates and closes, even though the log file is being modified in real time. I believe that this is because the log file is being used by the program. If I make another text file in that directory, open it up, write something in it, and save it, the on_modified is called when I save it. If I try to delete that file while it is opened in notepad, the file will be deleted successfully. However, for the log file, I get a file in use error. I believe this might be the reason watchdog can't capture the moment of its modification. Any suggestions to resolve or bypass this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source