projects
/
python_utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Take a lock before reading cross thread.
[python_utils.git]
/
executors.py
diff --git
a/executors.py
b/executors.py
index 9a732488fd718522782887deffc36b623f116c6e..426937142437db6e46af93ec8ef6a17376ee8991 100644
(file)
--- a/
executors.py
+++ b/
executors.py
@@
-36,7
+36,7
@@
import histogram as hist
import string_utils
from ansi import bg, fg, reset, underline
from decorator_utils import singleton
import string_utils
from ansi import bg, fg, reset, underline
from decorator_utils import singleton
-from exec_utils import cmd_
in_background, cmd_with_timeout
, run_silently
+from exec_utils import cmd_
exitcode, cmd_in_background
, run_silently
from thread_utils import background_thread
logger = logging.getLogger(__name__)
from thread_utils import background_thread
logger = logging.getLogger(__name__)
@@
-150,7
+150,10
@@
class ThreadExecutor(BaseExecutor):
workers = max_workers
elif 'executors_threadpool_size' in config.config:
workers = config.config['executors_threadpool_size']
workers = max_workers
elif 'executors_threadpool_size' in config.config:
workers = config.config['executors_threadpool_size']
- logger.debug('Creating threadpool executor with %d workers', workers)
+ if workers is not None:
+ logger.debug('Creating threadpool executor with %d workers', workers)
+ else:
+ logger.debug('Creating a default sized threadpool executor')
self._thread_pool_executor = fut.ThreadPoolExecutor(
max_workers=workers, thread_name_prefix="thread_executor_helper"
)
self._thread_pool_executor = fut.ThreadPoolExecutor(
max_workers=workers, thread_name_prefix="thread_executor_helper"
)
@@
-203,7
+206,10
@@
class ProcessExecutor(BaseExecutor):
workers = max_workers
elif 'executors_processpool_size' in config.config:
workers = config.config['executors_processpool_size']
workers = max_workers
elif 'executors_processpool_size' in config.config:
workers = config.config['executors_processpool_size']
- logger.debug('Creating processpool executor with %d workers.', workers)
+ if workers is not None:
+ logger.debug('Creating processpool executor with %d workers.', workers)
+ else:
+ logger.debug('Creating a default sized processpool executor')
self._process_executor = fut.ProcessPoolExecutor(
max_workers=workers,
)
self._process_executor = fut.ProcessPoolExecutor(
max_workers=workers,
)
@@
-1374,7
+1380,7
@@
class DefaultExecutors(object):
def _ping(host) -> bool:
logger.debug('RUN> ping -c 1 %s', host)
try:
def _ping(host) -> bool:
logger.debug('RUN> ping -c 1 %s', host)
try:
- x = cmd_
with_timeout
(f'ping -c 1 {host} >/dev/null 2>/dev/null', timeout_seconds=1.0)
+ x = cmd_
exitcode
(f'ping -c 1 {host} >/dev/null 2>/dev/null', timeout_seconds=1.0)
return x == 0
except Exception:
return False
return x == 0
except Exception:
return False