@@ -159,16 +159,26 @@ def sync_data(self):
159
159
if CLEAN_DIE :
160
160
for client_address in list (cache_conns .keys ()):
161
161
if web_return_data .get (client_address ) is None :
162
- logger .warning ("CLIENT_ADDRESS:{} remove client not in server cache_conns" .format (client_address ))
163
- self .die_client_address .append (client_address )
162
+ if cache_conns .get (client_address ).get ("new" ) is True :
163
+ cache_conns [client_address ]["new" ] = False
164
+ pass
165
+ else :
166
+ logger .warning (
167
+ "CLIENT_ADDRESS:{} remove client not in server CHCHE_CONNS" .format (client_address ))
168
+ logger .warning ("CLIENT_ADDRESS:{} append in die_client_address" .format (client_address ))
169
+ self .die_client_address .append (client_address )
170
+
164
171
165
172
166
173
class TCPClient (BaseRequestHandler ):
167
174
def handle (self ):
168
175
logger .warning ('Got connection from {}' .format (self .client_address ))
169
176
self .request .settimeout (SOCKET_TIMEOUT )
170
177
key = "{}:{}" .format (self .client_address [0 ], self .client_address [1 ])
171
- cache_conns [key ] = {"conn" : self .request }
178
+ cache_conns [key ] = {
179
+ "conn" : self .request ,
180
+ "new" : True , # 新的连接,第一次检查略过
181
+ }
172
182
while True :
173
183
time .sleep (10 ) # 维持tcp连接
174
184
@@ -198,7 +208,7 @@ def handle(self):
198
208
READ_BUFF_SIZE = int (configini .get ("TOOL-CONFIG" , "READ_BUFF_SIZE" ))
199
209
except Exception as E :
200
210
logger .exception (E )
201
- READ_BUFF_SIZE = 10240
211
+ READ_BUFF_SIZE = 51200
202
212
203
213
try :
204
214
SLEEP_TIME = float (configini .get ("TOOL-CONFIG" , "SLEEP_TIME" ))
@@ -208,7 +218,6 @@ def handle(self):
208
218
logger .exception (E )
209
219
SLEEP_TIME = 0.1
210
220
211
- READ_BUFF_SIZE = 10240
212
221
213
222
# socket_timeout
214
223
try :
0 commit comments