| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """This module contains util functions that local scripts can use.""" | 5 """This module contains util functions that local scripts can use.""" |
| 6 | 6 |
| 7 import atexit | 7 import atexit |
| 8 import functools | 8 import functools |
| 9 import os | 9 import os |
| 10 import Queue | 10 import Queue |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 dev_appserver.fix_sys_path() | 36 dev_appserver.fix_sys_path() |
| 37 | 37 |
| 38 # Add Findit root dir to sys.path so that modules in Findit is available. | 38 # Add Findit root dir to sys.path so that modules in Findit is available. |
| 39 sys.path.insert(1, findit_root_dir) | 39 sys.path.insert(1, findit_root_dir) |
| 40 | 40 |
| 41 | 41 |
| 42 SetUpSystemPaths() | 42 SetUpSystemPaths() |
| 43 | 43 |
| 44 # The lib is in predator/ root dir, and can be imported only when sys.path gets | 44 # The lib is in predator/ root dir, and can be imported only when sys.path gets |
| 45 # set up. | 45 # set up. |
| 46 from lib.cache_decorator import Cached | 46 from libs.cache_decorator import Cached |
| 47 from local_cache import LocalCache # pylint: disable=W | 47 from local_cache import LocalCache # pylint: disable=W |
| 48 | 48 |
| 49 | 49 |
| 50 def SignalWorkerThreads(): # pragma: no cover | 50 def SignalWorkerThreads(): # pragma: no cover |
| 51 """Puts signal worker threads into task queue.""" | 51 """Puts signal worker threads into task queue.""" |
| 52 global TASK_QUEUE # pylint: disable=W0602 | 52 global TASK_QUEUE # pylint: disable=W0602 |
| 53 if not TASK_QUEUE: | 53 if not TASK_QUEUE: |
| 54 return | 54 return |
| 55 | 55 |
| 56 for _ in range(MAX_THREAD_NUMBER): | 56 for _ in range(MAX_THREAD_NUMBER): |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 def GetLockedMethod(cls, method_name, lock): # pragma: no cover | 148 def GetLockedMethod(cls, method_name, lock): # pragma: no cover |
| 149 """Returns a class/object method serialized with lock.""" | 149 """Returns a class/object method serialized with lock.""" |
| 150 method = getattr(cls, method_name) | 150 method = getattr(cls, method_name) |
| 151 | 151 |
| 152 def LockedMethod(cls, *args, **kwargs): # pylint: disable=W | 152 def LockedMethod(cls, *args, **kwargs): # pylint: disable=W |
| 153 with lock: | 153 with lock: |
| 154 return method(*args, **kwargs) | 154 return method(*args, **kwargs) |
| 155 | 155 |
| 156 return functools.partial(LockedMethod, cls) | 156 return functools.partial(LockedMethod, cls) |
| OLD | NEW |