|
- from traceback import format_exc
-
- from loguru import logger
-
- from enums.ExceptionEnum import ExceptionType
- from exception.CustomerException import ServiceException
-
-
- def get_no_block_queue(queue):
- eBody = None
- try:
- eBody = queue.get(block=False)
- except Exception:
- pass
- return eBody
-
-
- def get_block_queue(queue):
- eBody = None
- try:
- eBody = queue.get()
- except Exception:
- pass
- return eBody
-
-
- def put_queue(queue, result, requestId='1', timeout=30, is_throw_ex=True):
- try:
- queue.put(result, timeout=timeout)
- except Exception:
- if is_throw_ex:
- logger.error("添加队列异常:{}, requestId:{}", format_exc(), requestId)
- raise ServiceException(ExceptionType.SERVICE_INNER_EXCEPTION.value[0],
- ExceptionType.SERVICE_INNER_EXCEPTION.value[1])
|