On 25/04/2021 20:50, Zoran wrote:
>> <
https://duckduckgo.com/?q=python+file+system+watcher>
>>
>> Implementations are usually just callback-based. (Apologies for the
>> generic link, I haven't needed this in Python yet: anyway, those are the
>> keywords.)
>
> :) before asking a question here I googled the subject a lot.
Maybe, still you have snipped and altogether missed the actual point of
my answer, which was that of indicating an alternative approach to the
async notifiers that you guys had been considering up-thread.
> Anyway, the simplest solution is this one:
>
> import asyncio
> import pathlib
> from watchgod import awatch, Change
>
> watch_dir = pathlib.Path(r'C:\Users\User\watch_folder')
>
>
> async def main():
> async for changes in awatch(str(watch_dir)):
> while changes:
> change_type, path = changes.pop()
> if change_type == Change.added:
> print('processing:', path)
>
>
> loop = asyncio.get_event_loop()
> loop.run_until_complete(main())
>
> watchgod library is quite young. I hope that there will be no suprises.
Notice also that this is a public forum, so, not just for your info, I
suppose you mean this one: <
https://github.com/samuelcolvin/watchgod>
FWIW, at my cursory inspection, looks clean and alive...
HTH,
Julio