Author: dmeyer
Date: Tue Jan  8 15:21:09 2008
New Revision: 2962

Log:
resort functions

Modified:
   trunk/base/src/notifier/main.py

Modified: trunk/base/src/notifier/main.py
==============================================================================
--- trunk/base/src/notifier/main.py     (original)
+++ trunk/base/src/notifier/main.py     Tue Jan  8 15:21:09 2008
@@ -46,7 +46,8 @@
 from jobserver import killall as kill_jobserver
 from decorators import execute_in_mainloop
 
-__all__ = [ 'init', 'start', 'stop', 'step', 'is_running', 'wakeup', 
'set_as_mainthread', 'is_shutting_down' ]
+__all__ = [ 'start', 'stop', 'step', 'select_notifier', 'is_running', 'wakeup',
+            'set_as_mainthread', 'is_shutting_down' ]
 
 # get logging object
 log = logging.getLogger('notifier')
@@ -69,41 +70,14 @@
 }
 
 
-# Ensure stop() is called from main thread.
[EMAIL PROTECTED](async = True)
-def stop():
+def select_notifier(module, **options):
     """
-    Shutdown notifier and kill all background processes.
+    Initialize the specified notifier.
     """
-    global _shutting_down
-
-    if _running:
-        # notifier loop still running, send system exit
-        log.info('Stop notifier loop')
-        raise SystemExit
-
-    if _shutting_down:
-        return
-
-    _shutting_down = True
-
-    _proclist.stop_all()
-    signals["shutdown"].emit()
-    signals["shutdown"].disconnect_all()
-    signals["step"].disconnect_all()
-
-    # Kill processes _after_ shutdown emits to give callbacks a chance to
-    # close them properly.
-    _proclist.kill_all()
-    while _proclist.check():
-        # wait until all processes are stopped
-        step()
-    kill_jobserver()
-    # Collect any zombies
-    try:
-        os.waitpid(-1, os.WNOHANG)
-    except:
-        pass
+    if module in ('thread', 'twisted'):
+        import nf_thread
+        return nf_thread.init(module, **options)
+    return notifier.init( module, **options )
 
 
 def start():
@@ -135,24 +109,41 @@
     stop()
 
 
-def is_running():
-    return _running
+# Ensure stop() is called from main thread.
[EMAIL PROTECTED](async = True)
+def stop():
+    """
+    Shutdown notifier and kill all background processes.
+    """
+    global _shutting_down
 
-def is_shutting_down():
-    return _shutting_down
+    if _running:
+        # notifier loop still running, send system exit
+        log.info('Stop notifier loop')
+        raise SystemExit
 
-def _set_running(status):
-    global _running
-    _running = status
+    if _shutting_down:
+        return
 
-def select_notifier(module, **options):
-    """
-    Initialize the specified notifier.
-    """
-    if module in ('thread', 'twisted'):
-        import nf_thread
-        return nf_thread.init(module, **options)
-    return notifier.init( module, **options )
+    _shutting_down = True
+
+    _proclist.stop_all()
+    signals["shutdown"].emit()
+    signals["shutdown"].disconnect_all()
+    signals["step"].disconnect_all()
+
+    # Kill processes _after_ shutdown emits to give callbacks a chance to
+    # close them properly.
+    _proclist.kill_all()
+    while _proclist.check():
+        # wait until all processes are stopped
+        step()
+    kill_jobserver()
+    # Collect any zombies
+    try:
+        os.waitpid(-1, os.WNOHANG)
+    except:
+        pass
 
 
 def step(*args, **kwargs):
@@ -173,6 +164,29 @@
         raise SystemExit
 
 
+def is_running():
+    """
+    Return if the main loop is currently running.
+    """
+    return _running
+
+
+def is_shutting_down():
+    """
+    Return if the mainloop is currently inside stop()
+    """
+    return _shutting_down
+
+
+def _set_running(status):
+    """
+    Set running status. This function is only for the thread based notifier
+    since it does not call start().
+    """
+    global _running
+    _running = status
+
+
 def _shutdown_check(*args):
     # Helper function to shutdown kaa on system exit
     # The problem is that pytgtk just exits python and

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to