Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 0d68935c1 -> a9951bad1


AMBARI-20070. Agent heartbeat loop stuck in subprocess.Popen (adoroszlai)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/a9951bad
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a9951bad
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a9951bad

Branch: refs/heads/branch-2.5
Commit: a9951bad101fef5c5449260ff7589b220edc5b13
Parents: 0d68935
Author: Attila Doroszlai <[email protected]>
Authored: Mon Feb 20 10:40:57 2017 +0100
Committer: Attila Doroszlai <[email protected]>
Committed: Mon Feb 20 10:40:57 2017 +0100

----------------------------------------------------------------------
 .../src/main/python/ambari_agent/main.py        | 23 ++++++++++++++++++++
 1 file changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a9951bad/ambari-agent/src/main/python/ambari_agent/main.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/main.py 
b/ambari-agent/src/main/python/ambari_agent/main.py
index 8e577a5..3f333c4 100644
--- a/ambari-agent/src/main/python/ambari_agent/main.py
+++ b/ambari-agent/src/main/python/ambari_agent/main.py
@@ -42,6 +42,29 @@ def fix_subprocess_racecondition():
   del sys.modules['gc']
   import gc
 
+
+def fix_subprocess_popen():
+  '''
+  http://bugs.python.org/issue19809
+  '''
+  import os
+  import sys
+
+  if os.name == 'posix' and sys.version_info[0] < 3:
+    import subprocess
+    import threading
+
+    original_init = subprocess.Popen.__init__
+    lock = threading.RLock()
+
+    def locked_init(self, *a, **kw):
+      with lock:
+        original_init(self, *a, **kw)
+
+    subprocess.Popen.__init__ = locked_init
+
+
+fix_subprocess_popen()
 fix_subprocess_racecondition()
 fix_encoding_reimport_bug()
 

Reply via email to