Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Workspace save-as sometimes fails on Windows #764

Closed
forman opened this issue Sep 24, 2018 · 1 comment
Closed

Workspace save-as sometimes fails on Windows #764

forman opened this issue Sep 24, 2018 · 1 comment

Comments

@forman
Copy link
Member

forman commented Sep 24, 2018

Expected behavior

Workspace save-as should always save the current workspace into a new directory. If the original workspace is a scratch workspace (i.e. a new workspace). The scratch directory hall be removed.

Actual behavior

On Windows 10, the scratch directory is sometimes in use by another process, hence the OS denies accessing it. We get a PermissionError in Python when trying to delete it:

Job: Save workspace as "C:\Users\Norman\Cate-Workspaces/scatter"
Message: [WinError 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'C:\\Users\\Norman\\.cate\\scratch\\74380265-536b-476d-8dc8-b7c28eb309a7'
Code: -32001
Method: save_workspace_as
Exception: PermissionError

Traceback (most recent call last):
  File "C:\Users\Norman\IdeaProjects\ccitools\cate\cate\util\web\jsonrpchandler.py", line 209, in send_service_method_result
    result = future.result()
  File "C:\Users\Norman\Miniconda3\envs\cate-env\lib\concurrent\futures\_base.py", line 425, in result
    return self.__get_result()
  File "C:\Users\Norman\Miniconda3\envs\cate-env\lib\concurrent\futures\_base.py", line 384, in __get_result
    raise self._exception
  File "C:\Users\Norman\Miniconda3\envs\cate-env\lib\concurrent\futures\thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "C:\Users\Norman\IdeaProjects\ccitools\cate\cate\util\web\jsonrpchandler.py", line 306, in call_service_method
    result = method(*method_params, monitor=monitor)
  File "C:\Users\Norman\IdeaProjects\ccitools\cate\cate\webapi\websocket.py", line 258, in save_workspace_as
    workspace = self.workspace_manager.save_workspace_as(base_dir, to_dir, monitor=monitor)
  File "C:\Users\Norman\IdeaProjects\ccitools\cate\cate\core\wsmanag.py", line 255, in save_workspace_as
    shutil.rmtree(base_dir)
  File "C:\Users\Norman\Miniconda3\envs\cate-env\lib\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\Norman\Miniconda3\envs\cate-env\lib\shutil.py", line 393, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Users\Norman\Miniconda3\envs\cate-env\lib\shutil.py", line 391, in _rmtree_unsafe
    os.rmdir(path)
PermissionError: [WinError 32] Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird: 'C:\\Users\\Norman\\.cate\\scratch\\74380265-536b-476d-8dc8-b7c28eb309a7'

Steps to reproduce the problem

  1. Create new workspace
  2. Add some operation steps
  3. Save As

Specifications

Cate 2.0.0.dev18, Windows 10

@forman
Copy link
Member Author

forman commented Sep 24, 2018

Quick fix is to catch and ignore the error as the new workspace is saved-as without problems.
However, we must clean up scratch workspaces from time to time when Cate starts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant