Possible bug: case folder locked after solver termination

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

RatonLaveur
Posts: 978
Joined: Wed Mar 27, 2019 10:45 am

Possible bug: case folder locked after solver termination

Postby RatonLaveur » Tue Feb 23, 2021 7:15 am

Hi,

I may have encountered a bug where the directory for the solver is locked for edition after terminating a solver.

Please find the relevant lines in the report console:

Code: Select all

Time = 1

08:05:42  No handles with labels found to put in legend.
08:10:38  Wrapper process received terminate command
08:10:38  No handles with labels found to put in legend.
08:10:39  Traceback (most recent call last):
08:10:39    File "C:\Users\xxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdResidualPlot.py", line 72, in refresh
08:10:39      self.fig.canvas.draw()
08:10:39    File "C:\Program Files\FreeCAD\FreeCAD_0.19.23970_Win-LPv12.1.6_vc14.x-x86-64\bin\lib\site-packages\matplotlib\backends\backend_agg.py", line 405, in draw
08:10:39      super().draw()
08:10:39    File "C:\Program Files\FreeCAD\FreeCAD_0.19.23970_Win-LPv12.1.6_vc14.x-x86-64\bin\lib\site-packages\matplotlib\backends\backend_qt5.py", line 499, in draw
08:10:39      self.update()
08:10:39  RuntimeError: Internal C++ object (FigureCanvasQTAgg) already deleted.
08:10:56  Writing case to folder C:\Users\jdiboine\Desktop\Results\000_TempCFDoF
08:10:56  Traceback (most recent call last):
08:10:56    File "C:\Users\xxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\_TaskPanelCfdSolverControl.py", line 122, in write_input_file_handler
08:10:56      FreeCADGui.doCommand("writer.writeCase()")
08:10:56    File "<string>", line 1, in <module>
08:10:56    File "C:\Users\xxxxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 106, in writeCase
08:10:56      self.clearCase()
08:10:56    File "C:\Users\xxxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 201, in clearCase
08:10:56      shutil.rmtree(output_path)
08:10:56    File "shutil.py", line 500, in rmtree
08:10:56      return _rmtree_unsafe(path, onerror)
08:10:56    File "shutil.py", line 399, in _rmtree_unsafe
08:10:56      onerror(os.rmdir, path, sys.exc_info())
08:10:56    File "shutil.py", line 397, in _rmtree_unsafe
08:10:56      os.rmdir(path)
08:10:56  PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\xxxxxxx\\Desktop\\Results\\000_TempCFDoF\\case'
08:11:00  Writing case to folder C:\Users\xxxxxxxx\Desktop\Results\000_TempCFDoF
08:11:00  Traceback (most recent call last):
08:11:00    File "C:\Users\xxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\_TaskPanelCfdSolverControl.py", line 122, in write_input_file_handler
08:11:00      FreeCADGui.doCommand("writer.writeCase()")
08:11:00    File "<string>", line 1, in <module>
08:11:00    File "C:\Users\xxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 106, in writeCase
08:11:00      self.clearCase()
08:11:00    File "C:\Users\xxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 201, in clearCase
08:11:00      shutil.rmtree(output_path)
08:11:00    File "shutil.py", line 500, in rmtree
08:11:00      return _rmtree_unsafe(path, onerror)
08:11:00    File "shutil.py", line 399, in _rmtree_unsafe
08:11:00      onerror(os.rmdir, path, sys.exc_info())
08:11:00    File "shutil.py", line 397, in _rmtree_unsafe
08:11:00      os.rmdir(path)
08:11:00  PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\xxxxxxx\\Desktop\\Results\\000_TempCFDoF\\case'
You may also find the message received in the solver print feed:
2021-02-23 08_11_02-FreeCAD 0.19.png
2021-02-23 08_11_02-FreeCAD 0.19.png (5.28 KiB) Viewed 519 times
OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23970 (Git)
Build type: Release
Branch: master
Hash: a30cf5b4df22cf43f58211210b70183a7d6c17aa
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Switzerland (en_CH)
User avatar
oliveroxtoby
Posts: 500
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: Possible bug: case folder locked after solver termination

Postby oliveroxtoby » Tue Feb 23, 2021 5:24 pm

RatonLaveur wrote: Tue Feb 23, 2021 7:15 am Hi,

I may have encountered a bug where the directory for the solver is locked for edition after terminating a solver.

Please find the relevant lines in the report console:

Code: Select all

Time = 1

08:05:42  No handles with labels found to put in legend.
08:10:38  Wrapper process received terminate command
08:10:38  No handles with labels found to put in legend.
08:10:39  Traceback (most recent call last):
08:10:39    File "C:\Users\xxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdResidualPlot.py", line 72, in refresh
08:10:39      self.fig.canvas.draw()
08:10:39    File "C:\Program Files\FreeCAD\FreeCAD_0.19.23970_Win-LPv12.1.6_vc14.x-x86-64\bin\lib\site-packages\matplotlib\backends\backend_agg.py", line 405, in draw
08:10:39      super().draw()
08:10:39    File "C:\Program Files\FreeCAD\FreeCAD_0.19.23970_Win-LPv12.1.6_vc14.x-x86-64\bin\lib\site-packages\matplotlib\backends\backend_qt5.py", line 499, in draw
08:10:39      self.update()
08:10:39  RuntimeError: Internal C++ object (FigureCanvasQTAgg) already deleted.
08:10:56  Writing case to folder C:\Users\jdiboine\Desktop\Results\000_TempCFDoF
08:10:56  Traceback (most recent call last):
08:10:56    File "C:\Users\xxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\_TaskPanelCfdSolverControl.py", line 122, in write_input_file_handler
08:10:56      FreeCADGui.doCommand("writer.writeCase()")
08:10:56    File "<string>", line 1, in <module>
08:10:56    File "C:\Users\xxxxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 106, in writeCase
08:10:56      self.clearCase()
08:10:56    File "C:\Users\xxxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 201, in clearCase
08:10:56      shutil.rmtree(output_path)
08:10:56    File "shutil.py", line 500, in rmtree
08:10:56      return _rmtree_unsafe(path, onerror)
08:10:56    File "shutil.py", line 399, in _rmtree_unsafe
08:10:56      onerror(os.rmdir, path, sys.exc_info())
08:10:56    File "shutil.py", line 397, in _rmtree_unsafe
08:10:56      os.rmdir(path)
08:10:56  PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\xxxxxxx\\Desktop\\Results\\000_TempCFDoF\\case'
08:11:00  Writing case to folder C:\Users\xxxxxxxx\Desktop\Results\000_TempCFDoF
08:11:00  Traceback (most recent call last):
08:11:00    File "C:\Users\xxxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\_TaskPanelCfdSolverControl.py", line 122, in write_input_file_handler
08:11:00      FreeCADGui.doCommand("writer.writeCase()")
08:11:00    File "<string>", line 1, in <module>
08:11:00    File "C:\Users\xxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 106, in writeCase
08:11:00      self.clearCase()
08:11:00    File "C:\Users\xxxxxxx\AppData\Roaming\FreeCAD\Mod\CfdOF\CfdCaseWriterFoam.py", line 201, in clearCase
08:11:00      shutil.rmtree(output_path)
08:11:00    File "shutil.py", line 500, in rmtree
08:11:00      return _rmtree_unsafe(path, onerror)
08:11:00    File "shutil.py", line 399, in _rmtree_unsafe
08:11:00      onerror(os.rmdir, path, sys.exc_info())
08:11:00    File "shutil.py", line 397, in _rmtree_unsafe
08:11:00      os.rmdir(path)
08:11:00  PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\xxxxxxx\\Desktop\\Results\\000_TempCFDoF\\case'
You may also find the message received in the solver print feed:
2021-02-23 08_11_02-FreeCAD 0.19.png

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.23970 (Git)
Build type: Release
Branch: master
Hash: a30cf5b4df22cf43f58211210b70183a7d6c17aa
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/Switzerland (en_CH)
Usually this happens if you have the folder open in an explorer window or something like that. Is that the case? Otherwise, could you give the exact steps to reproduce this? (I presume it happens when you re-run the simulation a second time?)
RatonLaveur
Posts: 978
Joined: Wed Mar 27, 2019 10:45 am

Re: Possible bug: case folder locked after solver termination

Postby RatonLaveur » Tue Feb 23, 2021 7:01 pm

Correct it happens when I re-run the simulation. Even without the folder open in explorer.

I can't elaborate more at the moment but will try to repeat the problem a few times.