Ren'Py WindowsError: [Error 32] The process cannot access the file because it is being used by another process

Nine of Swords

Keeping the Legends Alive
Game Developer
Dec 17, 2017
954
4,774
In the past two weeks or so, I've been getting a lot of Ren'Py crashes when modifying my code while the game is running, then using Shift + R to reload. I never had issues with this before, and I haven't updated Ren'Py so I'm not sure what would cause this issue now. After this sort of crash, sometimes it will prevent me from launching from Ren'Py for a while. Restarting the PC always fixes it, but it crashes nearly every time I modify any file while Ren'Py is running, and sometimes even when I modify a file while Ren'Py isn't running. I've tried deleting the *.rpyc files, but that doesn't seem to help.

This has spilled over into issues when trying to build distributions, so it takes me several tries to get it to work (Error - Launching the project failed. Please ensure that your project launches normally before running this command).

Here's the traceback:

Code:
I'm sorry, but an uncaught exception occurred.

After initialization, but before game start.
WindowsError: [Error 32] The process cannot access the file because it is being used by another process

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "renpy/bootstrap.py", line 326, in bootstrap
    renpy.main.main()
  File "renpy/main.py", line 567, in main
    renpy.dump.dump(False)
  File "renpy/dump.py", line 260, in dump
    os.rename(new, filename)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process

Windows-10-10.0.19041
Ren'Py 7.4.2.1292
Mythos 0.1.3
Sat Aug  7 20:17:12 2021
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,957
16,190
Code:
  File "renpy/dump.py", line 260, in dump
    os.rename(new, filename)
WindowsError: [Error 32] The process cannot access the file because it is being used by another process
For some reason, Python isn't freeing the JSON dump file ([path to project]/[project name]/game/saves/navigation.json).

The right answer should be to understand why, but adding this in your code should fix the problem:
Code:
init python:
    renpy.game.args.json_dump = None
I don't guaranty that Ren'py will accept the change, because it's something really dirty. But if it accept it, then it will stop dumping each time you reload. And Ren'py will not complain that it can't access the file, if it just don't want to access it.
 
  • Like
Reactions: Nine of Swords

Nine of Swords

Keeping the Legends Alive
Game Developer
Dec 17, 2017
954
4,774
For some reason, Python isn't freeing the JSON dump file ([path to project]/[project name]/game/saves/navigation.json).

The right answer should be to understand why, but adding this in your code should fix the problem:
Code:
init python:
    renpy.game.args.json_dump = None
I don't guaranty that Ren'py will accept the change, because it's something really dirty. But if it accept it, then it will stop dumping each time you reload. And Ren'py will not complain that it can't access the file, if it just don't want to access it.
I just stuck it in, and it looks like it's working for now, thanks!

I'll have to try to figure out that underlying issue, but at least I can work on my game in the meantime.