Skip to content
Snippets Groups Projects
Commit a5cf7bd7 authored by ctiller's avatar ctiller Committed by Nicolas Noble
Browse files

Remove mutex as this process is now single threaded

	Change on 2015/01/09 by ctiller <ctiller@google.com>
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=83610407
parent 8bf337be
No related branches found
No related tags found
No related merge requests found
"""Helper to watch a (set) of directories for modifications.""" """Helper to watch a (set) of directories for modifications."""
import os import os
import threading
import time import time
...@@ -11,7 +10,6 @@ class DirWatcher(object): ...@@ -11,7 +10,6 @@ class DirWatcher(object):
def __init__(self, paths): def __init__(self, paths):
if isinstance(paths, basestring): if isinstance(paths, basestring):
paths = [paths] paths = [paths]
self._mu = threading.Lock()
self._done = False self._done = False
self.paths = list(paths) self.paths = list(paths)
self.lastrun = time.time() self.lastrun = time.time()
...@@ -35,12 +33,8 @@ class DirWatcher(object): ...@@ -35,12 +33,8 @@ class DirWatcher(object):
return most_recent_change return most_recent_change
def most_recent_change(self): def most_recent_change(self):
self._mu.acquire() if time.time() - self.lastrun > 1:
try: self._cache = self._calculate()
if time.time() - self.lastrun > 1: self.lastrun = time.time()
self._cache = self._calculate() return self._cache
self.lastrun = time.time()
return self._cache
finally:
self._mu.release()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment