summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/python_modules
diff options
context:
space:
mode:
authorIlya Mashchenko <ilya@netdata.cloud>2020-07-09 15:31:52 +0300
committerGitHub <noreply@github.com>2020-07-09 15:31:52 +0300
commitb9f9d8f771a03d5f246cba23719585d0ebc90fae (patch)
treea39fc89f4d7635f6a82964dce891b9e0d7d8b4e8 /collectors/python.d.plugin/python_modules
parent58de77c82f758e1c32f2775ea7f0e4503f9e6e80 (diff)
python.d: thread safe safe_print (stdout write) (#9508)
Diffstat (limited to 'collectors/python.d.plugin/python_modules')
-rw-r--r--collectors/python.d.plugin/python_modules/bases/collection.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/collectors/python.d.plugin/python_modules/bases/collection.py b/collectors/python.d.plugin/python_modules/bases/collection.py
index 3b5b243e33..fe084332f7 100644
--- a/collectors/python.d.plugin/python_modules/bases/collection.py
+++ b/collectors/python.d.plugin/python_modules/bases/collection.py
@@ -5,6 +5,8 @@
import os
+from threading import Lock
+
PATH = os.getenv('PATH', '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin').split(':')
CHART_BEGIN = 'BEGIN {0} {1}\n'
@@ -12,6 +14,8 @@ CHART_CREATE = "CHART {0} '{1}' '{2}' '{3}' '{4}' '{5}' {6} {7} {8}\n"
DIMENSION_CREATE = "DIMENSION '{0}' '{1}' {2} {3} {4} '{5}'\n"
DIMENSION_SET = "SET '{0}' = {1}\n"
+print_lock = Lock()
+
def setdefault_values(config, base_dict):
for key, value in base_dict.items():
@@ -62,7 +66,9 @@ def safe_print(*msg):
:param msg:
:return:
"""
+ print_lock.acquire()
print(''.join(msg))
+ print_lock.release()
def find_binary(binary):