cc-4105: daemonized touching thread. fixed wrong method name bug. improved formatting

This commit is contained in:
Rudi Grinberg 2012-07-23 17:02:33 -04:00
parent a953a479d9
commit d76177aed1
3 changed files with 5 additions and 5 deletions

View File

@ -284,7 +284,7 @@ def last_modified(path):
exist we set this time 0 so that any files on the filesystem were modified after it exist we set this time 0 so that any files on the filesystem were modified after it
""" """
if os.path.exists(path): if os.path.exists(path):
os.path.gmtime(path) return os.path.getmtime(path)
else: 0 else: 0
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -13,9 +13,7 @@ class Toucher(Loggable):
self.logger.info("Failed to touch file: '%s'. Logging exception." % self.path) self.logger.info("Failed to touch file: '%s'. Logging exception." % self.path)
self.logger.info(str(e)) self.logger.info(str(e))
""" #http://code.activestate.com/lists/python-ideas/8982/
http://code.activestate.com/lists/python-ideas/8982/
"""
from datetime import datetime from datetime import datetime
import threading import threading
@ -61,7 +59,6 @@ class RepeatTimer(threading.Thread):
class ToucherThread(Loggable): class ToucherThread(Loggable):
"""docstring for ToucherThread"""
def __init__(self, path, interval=5): def __init__(self, path, interval=5):
if not os.path.exists(path): if not os.path.exists(path):
try: try:
@ -72,5 +69,6 @@ class ToucherThread(Loggable):
raise CouldNotCreateIndexFile(path,e) raise CouldNotCreateIndexFile(path,e)
cb = Toucher(path) cb = Toucher(path)
t = RepeatTimer(interval, cb) t = RepeatTimer(interval, cb)
t.daemon = True # thread terminates once process is done
t.start() t.start()

View File

@ -2,6 +2,7 @@
import pyinotify import pyinotify
import sys import sys
import os import os
from media.monitor.listeners import OrganizeListener, StoreWatchListener from media.monitor.listeners import OrganizeListener, StoreWatchListener
from media.monitor.organizer import Organizer from media.monitor.organizer import Organizer
from media.monitor.events import PathChannel from media.monitor.events import PathChannel
@ -15,6 +16,7 @@ from media.monitor.syncdb import SyncDB
from media.monitor.exceptions import FailedToObtainLocale, FailedToSetLocale, NoConfigFile from media.monitor.exceptions import FailedToObtainLocale, FailedToSetLocale, NoConfigFile
from media.monitor.airtime import AirtimeNotifier, AirtimeMessageReceiver from media.monitor.airtime import AirtimeNotifier, AirtimeMessageReceiver
import media.monitor.pure as mmp import media.monitor.pure as mmp
from api_clients import api_client as apc from api_clients import api_client as apc
log = get_logger() log = get_logger()