Reputation: 3284
I want to create a python script that polls a folder that a java server will fill with images when a user transfers them, however I want this script to be almost as invisible as possible in terms of noticeable effects. Keep in mind that this computer has many servers on it, and management of memory and speed are thing I want to optimize. How is the best way to poll this directory without it clogging up the system? Would I want to pull sleep functions in there, or does that cause even more problems?
Upvotes: 0
Views: 635
Reputation: 5599
If your server is Linux, the best and cleanest way to do this is with the system service inotify
, which is designed just for your needs. Python has a lib as a part of the twisted
network programming framework, which is loosely coupled, so you can use it while keeping it simple. Just check-out this example:
http://twistedmatrix.com/documents/10.2.0/api/twisted.internet.inotify.html
it is quite straight-forward.
Upvotes: 3