MessageListener.py 996 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from hub import methods, Global
  2. import threading
  3. import time
  4. import json
  5. import os
  6. # --- for linux
  7. # save_dir = f"/home/server/logs"
  8. # --- for windows
  9. # save_dir = r'C:\SRI-DINO.Server-py\logs' # sri内网测试环境
  10. save_dir = r'C:\logs' # sri内网测试环境
  11. class MessageListener(object):
  12. """
  13. """
  14. @classmethod
  15. def run(cls, background_is=True):
  16. from lib.UserWorkRecord import UserWorkRecord
  17. UserWorkRecord.init()
  18. from lib.MessageListenerC001 import subscribe_c001
  19. from lib.MessageListenerV001 import subscribe_v001
  20. thread_list = [
  21. threading.Thread(target=subscribe_c001),
  22. threading.Thread(target=subscribe_v001),
  23. ]
  24. for thread in thread_list:
  25. thread.setDaemon(True)
  26. thread.start()
  27. if background_is:
  28. return
  29. for thread in thread_list:
  30. thread.join()
  31. if __name__ == '__main__':
  32. # --- test ---
  33. MessageListener.run()