[Erp5-report] r45840 luke - in /erp5/trunk/utils/Products.TIDStorage: ./ Products/TIDStorag...

nobody at svn.erp5.org nobody at svn.erp5.org
Thu May 5 10:22:48 CEST 2011


Author: luke
Date: Thu May  5 10:22:48 2011
New Revision: 45840

URL: http://svn.erp5.org?rev=45840&view=rev
Log:
Run tidstorage by method, not during import time.

Solves problem of non working socket operation in threads.

Modified:
    erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py
    erp5/trunk/utils/Products.TIDStorage/setup.py

Modified: erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py
URL: http://svn.erp5.org/erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py?rev=45840&r1=45839&r2=45840&view=diff
==============================================================================
--- erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py [utf8] (original)
+++ erp5/trunk/utils/Products.TIDStorage/Products/TIDStorage/bin/tidstorage.py [utf8] Thu May  5 10:22:48 2011
@@ -700,40 +700,46 @@ if options.setgid is not None:
 if options.setuid is not None:
   os.setuid(options.setuid)
 
-tid_storage = TIDStorage(tid_file_path=options.status_file,
-                         burst_period=options.burst_period,
-                         full_dump_period=options.full_dump_period)
-
-signal.signal(signal.SIGHUP, HUPHandler)
-signal.signal(signal.SIGUSR1, USR1Handler)
-signal.signal(signal.SIGTERM, TERMHandler)
-
-tid_file = openTIDLog()
-sys.stdout = sys.stderr = openLog()
-
-pidfile = open(options.pidfile_name, 'w')
-if options.fork:
-  os.chdir('/')
-  os.umask(027)
-  pid = os.fork()
-  if pid == 0:
-    os.setsid()
+tid_storage = None
+def main():
+  global tid_storage
+  tid_storage = TIDStorage(tid_file_path=options.status_file,
+                           burst_period=options.burst_period,
+                           full_dump_period=options.full_dump_period)
+
+  signal.signal(signal.SIGHUP, HUPHandler)
+  signal.signal(signal.SIGUSR1, USR1Handler)
+  signal.signal(signal.SIGTERM, TERMHandler)
+
+  tid_file = openTIDLog()
+  sys.stdout = sys.stderr = openLog()
+
+  pidfile = open(options.pidfile_name, 'w')
+  if options.fork:
+    os.chdir('/')
+    os.umask(027)
     pid = os.fork()
     if pid == 0:
-      pidfile.close()
-      os.close(0)
-      os.close(1)
-      os.close(2)
-      server(options.address, options.port)
-      log('Exiting.')
+      os.setsid()
+      pid = os.fork()
+      if pid == 0:
+        pidfile.close()
+        os.close(0)
+        os.close(1)
+        os.close(2)
+        server(options.address, options.port)
+        log('Exiting.')
+      else:
+        pidfile.write(str(pid))
+        pidfile.close()
+        os._exit(0)
     else:
-      pidfile.write(str(pid))
-      pidfile.close()
       os._exit(0)
   else:
-    os._exit(0)
-else:
-  pidfile.write(str(os.getpid()))
-  pidfile.close()
-  server(options.address, options.port)
+    pidfile.write(str(os.getpid()))
+    pidfile.close()
+    server(options.address, options.port)
+
 
+if __name__ == '__main__':
+  main()

Modified: erp5/trunk/utils/Products.TIDStorage/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/Products.TIDStorage/setup.py?rev=45840&r1=45839&r2=45840&view=diff
==============================================================================
--- erp5/trunk/utils/Products.TIDStorage/setup.py [utf8] (original)
+++ erp5/trunk/utils/Products.TIDStorage/setup.py [utf8] Thu May  5 10:22:48 2011
@@ -30,7 +30,7 @@ setup(name='Products.TIDStorage',
       ],
       entry_points={
         'console_scripts': [
-          'tidstoraged = Products.TIDStorage.bin.tidstorage:__main__',
+          'tidstoraged = Products.TIDStorage.bin.tidstorage:main',
           'tidstorage_repozo = Products.TIDStorage.repozo.repozo_tidstorage:main',
         ]
       }



More information about the Erp5-report mailing list