Exemplo n.º 1
0
 def __init__(self, ip, bindport, thdpool_param):
     #  TODO: Close idle socket after 30 mins with no data sent or received.
     self._conns = {}
     self._bind_port = bindport
     self._bind_ip = ip
     self._epoll = select.epoll()
     self._stopsign = False
     self._bind_sock = None
     self._fileno2context = {}
     self._context2fileno_peer = {}
     self._peer2context = {}
     min_thds, max_thds = thdpool_param
     self._thdpool = threadpool.ThreadPool(min_thds,
                                           max_thds,
                                           name='network_write_read')
     self._recv_queue = queue.PriorityQueue(0)
     self._stopsign = False
     self._recv_msg_ind = 0
     self._mlock = threading.Lock()
     # _needack_context_queue
     # infinite queue  TODO:  may change it in the future
     self._needack_context_queue = queue.Queue()
     self._dict_lock = threading.Lock()
     self._needack_context_dict = {}
     self._executor = executor.ExecutionService(
         #int('queue_exec_thdnum'),    # todo num?
         #int('queue_delay_exe_thdnum')   # todo num?
         3,
         4)
     self._type_man = async_msg.CMsgType()
     self._type_man.register_types(async_msg.MSG_TYPE2NUM)
Exemplo n.º 2
0
 def __init__(self, delay_exe_thdnum=3, queue_exec_thdnum=4):
     self.__toal_thdnum = delay_exe_thdnum + queue_exec_thdnum
     self.__delay_exe_thdnum = delay_exe_thdnum
     self.__queue_exe_thdnum = queue_exec_thdnum
     self.__delay_queue = queue.PriorityQueue()
     self.__exec_queue = queue.PriorityQueue()
     self.__thdpool = threadpool.ThreadPool(self.__toal_thdnum,
                                            self.__toal_thdnum)
     self.__status = 0  # 0 inited, 1 running 2 stopping
     log.info('Executor service inited, delay_exec thread num:%d,'
              ' exec thread num:%d' % (delay_exe_thdnum, queue_exec_thdnum))
Exemplo n.º 3
0
 def __init__(self, delay_exe_thdnum, queue_exec_thdnum, name):
     """
     init
     """
     self._toal_thdnum = delay_exe_thdnum + queue_exec_thdnum
     self._delay_exe_thdnu = delay_exe_thdnum
     self._queue_exe_thdnum = queue_exec_thdnum
     self._delay_queue = queue.PriorityQueue()
     self._exec_queue = queue.PriorityQueue()
     self._thdpool = threadpool.ThreadPool(self._toal_thdnum,
                                           self._toal_thdnum,
                                           name='executor_pool')
     self._status = 0  # 0 inited, 1 running 2 stopping
     log.info('Executor service inited, delay_exec thread num:%d,'
              ' exec thread num:%d' % (delay_exe_thdnum, queue_exec_thdnum))
     self._name = '' if name is None else name
Exemplo n.º 4
0
    def __init__(self, ip, bindport, thdpool_param):
        #  TODO: Close idle socket after 30 mins with no data sent or received.
        self._conns = {}
        self._bind_port = bindport
        self._bind_ip = ip
        self._epoll = select.epoll()
        self._stopsign = False
        self._bind_sock = None
        self._fileno2context = {}
        self._context2fileno_peer = {}
        self._peer2context = {}
        #  self._kp_params = keepalive_params

        min_thds, max_thds = thdpool_param
        self._thdpool = threadpool.ThreadPool(min_thds, max_thds)
        self._recv_queue = queue.PriorityQueue(0)
        self._stopsign = False

        self._recv_msg_ind = 0