changeset acfc4dd4a177 in trytond:6.2
details: https://hg.tryton.org/trytond?cmd=changeset&node=acfc4dd4a177
description:
        Do not start status report on platform without AF_UNIX socket

        issue11319
        review393871002
        (grafted from f9c934230c6b1f7d8c5ee4a3722227ced19393ae)
diffstat:

 bin/trytond-stat  |  5 +++--
 trytond/status.py |  7 +++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diffs (49 lines):

diff -r 34ec02f528d7 -r acfc4dd4a177 bin/trytond-stat
--- a/bin/trytond-stat  Thu Mar 31 13:43:36 2022 +0200
+++ b/bin/trytond-stat  Fri Apr 01 23:48:06 2022 +0200
@@ -129,7 +129,8 @@
             processes[pid] = data
         refresh()
     refresh()
-    status.listen(config.get('database', 'path'), update)
+    return status.listen(config.get('database', 'path'), update)
 
 
-curses.wrapper(main)
+if not curses.wrapper(main):
+    sys.stderr.write("status not supported on this platform\n")
diff -r 34ec02f528d7 -r acfc4dd4a177 trytond/status.py
--- a/trytond/status.py Thu Mar 31 13:43:36 2022 +0200
+++ b/trytond/status.py Fri Apr 01 23:48:06 2022 +0200
@@ -49,6 +49,8 @@
 
 
 def dump(path):
+    if not hasattr(socket, 'AF_UNIX'):
+        return False
     sock = socket.socket(socket.AF_UNIX)
     try:
         try:
@@ -74,6 +76,8 @@
 
 def start(path):
     global _PID, _PATH
+    if not hasattr(socket, 'AF_UNIX'):
+        return
     if _PID != os.getpid() and path:  # Quick test without lock
         with _LOCK:
             if _PID != os.getpid():
@@ -84,6 +88,8 @@
 
 
 def listen(path, callback=None):
+    if not hasattr(socket, 'AF_UNIX'):
+        return False
     sock = socket.socket(socket.AF_UNIX)
     socket_file = os.path.join(path, address)
     try:
@@ -116,3 +122,4 @@
     finally:
         sock.close()
         os.unlink(socket_file)
+    return True

Reply via email to