Home > database >  Python TIME_WAIT state visit redis list queue appeared a lot of process, strives for the great god s
Python TIME_WAIT state visit redis list queue appeared a lot of process, strives for the great god s

Time:09-20

Question background: in one of the redis list type of object, the key - sha_list, python process inside A to sha_list push inside, 10 process B pop content from the inside, if B process when pop found no content, content sha_list process B ended,

Phenomenon is: sha_list has no content, but some (not all) process B has no end, view the process network status, found to be TIME_WAIT state, these processes have not been over,

Why is that? Why is there a part of the process in the TIME_WAIT state? Why the customer segment process B after being disconnected redis, will be in this state? What causes?


Process A code:
Def GetShaList (start_time, end_time, date) :
The pool=redis. ConnectionPool (host=HOST_IP, port=port, db=SHA_DB)
Conn_obj=redis. StrictRedis (connection_pool=pool)
| full_item="% s % s" % (start_time, end_time)
Conn_obj. Lpush (" sha_list full_item)


Process B code:
Def GetShaFromRedis () :
The pool=redis. ConnectionPool (host=HOST_IP, port=port, db=SHA_DB)
Conn_obj=redis. StrictRedis (connection_pool=pool)
If conn_obj. Llen (" sha_list ") & lt;=0:
Return None, None

Full_item=conn_obj. Lpop (" sha_list "). The split (' | ')
Sha_str_key=full_item [0]
Sha_date=full_item [1]

Return sha_str_key, sha_date

If __name__=="__main__" :
Sha_str_key, sha_date=GetShaFromRedis ()

There are a great god met this problem? Where is the root of the problem?

CodePudding user response:

Wrong, is CLOSE_WAIT state, will this and never put up? Where is the great god!

CodePudding user response:

When is estimated to be in a multithreaded if conn_obj. Llen (" sha_list ") & lt;=0: return None, None of this step is to judge when the queue is not empty, and then continue to execute down of time, the process of the element in the queue is another pick up empty, then the process of pop is blocked
  • Related