summaryrefslogtreecommitdiffstats
path: root/geo-replication/syncdaemon/syncdutils.py
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-09-24 20:56:21 +0530
committerShyamsundar Ranganathan <srangana@redhat.com>2018-10-05 14:22:46 +0000
commit3acb6955594402835dea8e309f202a9fc9e38ae0 (patch)
treea8c28148fee3a8edf5486f1efbe548125d943fb1 /geo-replication/syncdaemon/syncdutils.py
parente2b4e4e1ac8e3d419f7431ec9dad644e0f0fb75a (diff)
georep: Fix python3 compatibility (os.pipe)
'os.pipe' returns pair of file descriptors which are non-inheritable by child processes. But geo-rep uses te inheritable nature of pipe fds to communicate between parent and child processes. Hence wrote a compatiable pipe routine which works well both with python2 and python3 with inheritable nature. Updates: #411 Change-Id: I869d7a52eeecdecf3851d44ed400e69b32a612d9 Signed-off-by: Kotresh HR <khiremat@redhat.com> (cherry picked from commit 173e89a6506bc8c727ce6d8e5ac84b59ad2e21de)
Diffstat (limited to 'geo-replication/syncdaemon/syncdutils.py')
-rw-r--r--geo-replication/syncdaemon/syncdutils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
index a17789995d8..d13c1c82853 100644
--- a/geo-replication/syncdaemon/syncdutils.py
+++ b/geo-replication/syncdaemon/syncdutils.py
@@ -1018,3 +1018,15 @@ def get_up_nodes(hosts, port):
up_nodes.append(h)
return up_nodes
+
+
+def pipe():
+ # Pipe routine for python2 and python3 compatiability
+ try:
+ (r, w) = os.pipe()
+ os.set_inheritable(r, True)
+ os.set_inheritable(w, True)
+ except AttributeError:
+ (r, w) = os.pipe()
+
+ return (r, w)