Browse Source

[2582] Background the handling of commands

Michal 'vorner' Vaner 12 years ago
parent
commit
2283402c2b
1 changed files with 9 additions and 1 deletions
  1. 9 1
      src/bin/msgq/msgq.py.in

+ 9 - 1
src/bin/msgq/msgq.py.in

@@ -735,7 +735,15 @@ if __name__ == "__main__":
                                                  None, True,
                                                  msgq.socket_file)
             session.start()
-            # TODO: Background the session loop
+            # And we create a thread that'll just wait for commands and
+            # handle them. We don't terminate the thread, we set it to
+            # daemon. Once the main thread terminates, it'll just die.
+            def run_session():
+                while True:
+                    session.check_command(False)
+            background_thread = threading.Thread(target=run_session)
+            background_thread.daemon = True
+            background_thread.start()
         poller_thread.join()
     except KeyboardInterrupt:
         pass