python - How do I watch a file for changes? -
i have log file being written process want watch changes. each time change occurs i'd read new data in processing on it.
what's best way this? hoping there'd sort of hook pywin32 library. i've found win32file.findnextchangenotification
function have no idea how ask watch specific file.
if anyone's done i'd grateful hear how...
[edit] should have mentioned after solution doesn't require polling.
[edit] curses! seems doesn't work on mapped network drive. i'm guessing windows doesn't 'hear' updates file way on local disk.
have looked @ documentation available on http://timgolden.me.uk/python/win32_how_do_i/watch_directory_for_changes.html? if need work under windows 2nd example seems want (if exchange path of directory 1 of file want watch).
otherwise, polling platform-independent option.
note: haven't tried of these solutions.
Comments
Post a Comment