Skip to content

Commit e0277c0

Browse files
authored
Merge pull request #485 from FederatedAI/feature-1.11.2-deepspeed_log
Fix the issue of thread accumulation due to session cleanup timeouts.
2 parents cf4f333 + 2ef7f8f commit e0277c0

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

python/fate_flow/db/runtime_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class RuntimeConfig(ReloadConfigBase):
3838
SERVICE_DB = None
3939
LOAD_COMPONENT_REGISTRY = False
4040
LOAD_CONFIG_MANAGER = False
41+
SESSION_LIST = []
4142

4243
@classmethod
4344
def init_config(cls, **kwargs):

python/fate_flow/detection/detector.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,19 +225,23 @@ def detect_expired_session(cls):
225225
detect_logger().info(f'start detect expired session by ttl {ttl/1000} s')
226226
try:
227227
session_records = Session.query_sessions(create_time=[None, current_timestamp() - ttl])
228-
manager_session_id_list = []
229228
for session_record in session_records:
230229
manager_session_id = session_record.f_manager_session_id
231-
if manager_session_id in manager_session_id_list:
230+
if manager_session_id in RuntimeConfig.SESSION_LIST:
232231
continue
233-
manager_session_id_list.append(manager_session_id)
232+
else:
233+
RuntimeConfig.SESSION_LIST.append(manager_session_id)
234234
detect_logger().info(f'start destroy session {manager_session_id}')
235235
try:
236236
sess = Session(session_id=manager_session_id, options={"logger": detect_logger()})
237237
sess.destroy_all_sessions()
238238
except Exception as e:
239239
detect_logger().error(f'stop session {manager_session_id} error', e)
240240
finally:
241+
try:
242+
RuntimeConfig.SESSION_LIST.remove(manager_session_id)
243+
except:
244+
pass
241245
detect_logger().info(f'stop session {manager_session_id} successfully')
242246
except Exception as e:
243247
detect_logger().error('detect expired session error', e)

0 commit comments

Comments
 (0)