| | |
| | | import threading |
| | | import time |
| | | |
| | | from log_module.log import hx_logger_trade_debug |
| | | from utils import socket_util |
| | | |
| | | |
| | |
| | | client_list = sorted(cls.socket_client_dict[_type], key=lambda x: cls.active_client_dict.get(x[0]) if x[ |
| | | 0] in cls.active_client_dict else 0, |
| | | reverse=True) |
| | | hx_logger_trade_debug.info(f"acquire_client client_list数量:{len(client_list)}") |
| | | hx_logger_trade_debug.info(f"acquire_client socket_client_lock_dict数量:{len(cls.socket_client_lock_dict.keys())}") |
| | | for d in client_list: |
| | | if d[0] in cls.socket_client_lock_dict: |
| | | try: |
| | | if cls.socket_client_lock_dict[d[0]].acquire(blocking=False): |
| | | return d |
| | | except threading.TimeoutError: |
| | | pass |
| | | hx_logger_trade_debug.error("acquire_client TimeoutError") |
| | | else: |
| | | if _type in cls.socket_client_dict: |
| | | try: |