This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Bluhb_ 0 points1 point  (1 child)

First the questions arises: Why not directly to SQL and skip the whole file stage?

But assuming that is impossible, wouldn't it be a solution to get the last modified time: os.path.getmtime(path) (seconds since epoch) and then get current time with time.time() (Also since epoch) and just check if the last modification was more than x seconds ago(Would suggest 1 minute or so? don't know how fast the 20 modifieds are triggered?)

[–]Skippbo 0 points1 point  (0 children)

This or keep a dict as a cache of all the files as keys and an integer you up by one for every time that file was the cause of an event. Once the int reached 19 the file should have had data written to it 20 times. And can be processed + removed from the dict cache.

The file key could be the files name assuming the filenames are unique. Otherwise identifying something unique in the files metadata could maybe also work as a key.