Use `reduced_concurrency` as a fn decorator
@@ -93,8 +93,20 @@ def modify_thread_name(name, sink):
threading.current_thread().name = original_name
+@contextmanager
+def reduced_concurrency():
+ start_time = time.time()
+ with process_limit:
+ end_time = time.time()
+ waittime = end_time - start_time
+ if waittime > 0.1:
+ logger.warning('Waited in queue for {:.2f}s'.format(waittime))
+
+ yield
+
+
+@reduced_concurrency()
def execute_lint_task(linter, code, offset, view_has_changed):
- with reduced_concurrency():
try:
errors = linter.lint(code, view_has_changed) or []
finalize_errors(linter, errors, offset)
@@ -109,18 +121,6 @@ def execute_lint_task(linter, code, offset, view_has_changed):
return [] # Empty list here to clear old errors
-@contextmanager
-def reduced_concurrency():
- start_time = time.time()
- with process_limit:
- end_time = time.time()
- waittime = end_time - start_time
- if waittime > 0.1:
- logger.warning('Waited in queue for {:.2f}s'.format(waittime))
-
- yield
-
-
def finalize_errors(linter, errors, offset):
linter_name = linter.name
view = linter.view
