diff options
author | Kotresh HR <khiremat@redhat.com> | 2018-09-24 20:56:21 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-09-25 17:03:21 +0000 |
commit | 173e89a6506bc8c727ce6d8e5ac84b59ad2e21de (patch) | |
tree | 1ea0c403579f17c03a595ca1bda1c28d8e0c05b4 /geo-replication/syncdaemon/syncdutils.py | |
parent | 8f207feb260bc6112d5085859b43efc8378a4c5f (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>
Diffstat (limited to 'geo-replication/syncdaemon/syncdutils.py')
-rw-r--r-- | geo-replication/syncdaemon/syncdutils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py index 93e09756198..b2b866f8817 100644 --- a/geo-replication/syncdaemon/syncdutils.py +++ b/geo-replication/syncdaemon/syncdutils.py @@ -1016,3 +1016,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) |