0

Possible Duplicate:
Monitoring files/directories with python

I am making an API server that allows hot-deploying of code. And yes, there are dozens of questions about re-importing modules. I just want to monitor a directory, and when a change is detected, perform an action.

path_to_monitor="c:\\app\\package"
def action():
    do_something()
dm=dir_monitor(path_to_monitor,action)
dm.start()

I need a solution that is mature and cross-platform.

Community
  • 1
  • 1
Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202

1 Answers1

0

You can use a Python thread which uses os.listdir() to list files. If you want to monitor other file properties than the file name, os.stat might help you.

rocksportrocker
  • 7,251
  • 2
  • 31
  • 48