@@ -1062,18 +1062,37 @@ def send_task(self, model_name, task):
10621062 # Send the TASK to the model with the task queue and the pipe to send the response
10631063 self .workers [model_name ].task_queue .put ((child_conn ,) + task )
10641064
1065- # CLose the not needed connection
1066- # child_conn.close()
1067-
10681065 # Update the worker model info with the invocation
1069- self .workers [model_name ].worker_model_info .last_call = datetime .now ()
1070- self .workers [model_name ].worker_model_info .expires_at = datetime .now () + timedelta (minutes = int (rkllama .config .get ("model" , "max_minutes_loaded_in_memory" )),)
1066+ self .update_last_call_for_model (model_name )
10711067
10721068 # Return the request parent pipe
10731069 return parent_conn
10741070
10751071 return None
10761072
1073+
1074+ def update_last_call_for_model (self , model_name ):
1075+ """
1076+ Update the metadata of a worker with the last time called
1077+ Args:
1078+ model_name (str): Model to update
1079+ """
1080+ # Update the last call of the model
1081+ self .workers [model_name ].worker_model_info .last_call = datetime .now ()
1082+
1083+ # Update the expiration of the model
1084+ self .update_expiration_date_for_model (model_name )
1085+
1086+
1087+ def update_expiration_date_for_model (self , model_name ):
1088+ """
1089+ Update the metadata of a worker with the expiration date for the model
1090+ Args:
1091+ model_name (str): Model to update
1092+ """
1093+ # Update the expiration of the model
1094+ self .workers [model_name ].worker_model_info .expires_at = datetime .now () + timedelta (minutes = int (rkllama .config .get ("model" , "max_minutes_loaded_in_memory" )),)
1095+
10771096
10781097 def stop_worker (self , model_name , timeout = 30 ):
10791098 """
0 commit comments