PyMAPDL exits intermittently while running in a loop when mapdl.input() command is used


I'm encountering an issue while running a PyMAPDL script in a for-loop for a large number of iterations (approximately 8000). In each iteration, I modify the node locations using an input file and then solve the problem. To change the node locations, I utilize the "mapdl.input(update_nodes.inp)" command, which executes a sequence of commands from the "update_nodes.inp" file (e.g., "n,x,y,z").

Unfortunately, after a few iterations, Mapdl terminates unexpectedly with the following error message:

CRITICAL - pymapdl_global - logging - handle_exception - Uncaught exception
Traceback (most recent call last):
File "d:\bitBucket\fcdslib_modalSensitivity\ModalSensitivity\", line 33, in
result = obj.perform_modelSensitivity(niter=None)
File "d:\bitBucket\fcdslib_modalSensitivity\ModalSensitivity\", line 73, in perform_modelSensitivity
disp_pert[iter,:] = self.perturb_surf_nds(seed=0)
File "d:\bitBucket\fcdslib_modalSensitivity\ModalSensitivity\", line 168, in perturb_surf_nds
surf_ndInd_to_modfy = self._extract_surf_node_ind_modfy(surf_grid)
File "d:\bitBucket\fcdslib_modalSensitivity\ModalSensitivity\", line 146, in _extract_surf_node_ind_modfy
File "d:\bitBucket\fcdslib_modalSensitivity\ModalSensitivity\", line 143, in input_file
File "D:\PythonVenvs\sensitivityAnalysis\sensitivityAnalysis\lib\site-packages\ansys\mapdl\core\", line 168, in
raise MapdlExitedError("MAPDL server connection terminated") from None
ansys.mapdl.core.errors.MapdlExitedError: MAPDL server connection terminated

I have identified that this issue is related to the stability of the "mapdl.input()" command. I'm seeking alternative solutions to address this problem.

P.S: I have explored other options such as using "mapdl.n()" and "mapdl.ngen()" commands to change node locations, but they are too slow for my needs. I also attempted to run the commands in non-interactive mode, but that also proved to be slower compared to using an input file.

Thank you in advance for your assistance.