async watch directory for new files

Chris Angelico rosuav at gmail.com
Sat Apr 24 16:59:04 EDT 2021


On Sun, Apr 25, 2021 at 6:16 AM Zoran <zljubisic at gmail.com> wrote:
>
> On Saturday, 24 April 2021 at 18:52:24 UTC+2, Dieter Maurer wrote:
> > Zoran wrote at 2021-4-23 14:31 -0700:
> > >I need to watch for new files in directory, and when it shows up, I should create async task with file's full path for it, and wait for new file.
> > >
> > >If anyone here used a library for such task, please share which one.
> > The solution likely depends on the OS you are using.
> >
> > For Linux, `inotify` informs applications about file system changes.
> > PyPI contains a binding for it -- with identical name.
>
> As I can see https://pypi.org/project/inotify/ is not asyncio frendly.
> Whatever I use, it should be asynchronous.
> Final OS is linux (Centos 7), but I am doing development on Windows 10 machine, so it would be nice if I have something that works on both.

Bear in mind that asyncio is NOT the only way to be asynchronous. So
what you're asking for is, very specifically, an asyncio-compatible
inotify. Turns out, there's an ainotify on PyPI that might be what you
want.

ChrisA


More information about the Python-list mailing list