You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
713B

  1. from threading import Thread
  2. from loguru import logger
  3. class Common(Thread):
  4. __slots__ = [
  5. '__context',
  6. '__func',
  7. '__param1',
  8. '__param2',
  9. '__result',
  10. ]
  11. def __init__(self, context, func, param1, param2):
  12. super(Common, self).__init__()
  13. self.__context = context
  14. self.__func = func
  15. self.__param1 = param1
  16. self.__param2 = param2
  17. self.__result = None
  18. def get_result(self):
  19. self.join(60 * 60 * 12)
  20. return self.__result
  21. def run(self):
  22. logger.info("开始执行线程!")
  23. self.__result = self.__func(self.__param1, self.__param2)
  24. logger.info("线程停止完成!")