SUSTechGameAI / GVGAI_GYM

Apache License 2.0
11 stars 7 forks source link

io.socket not closing #9

Open jellevankerk opened 3 years ago

jellevankerk commented 3 years ago

Hi, we were trying to set up the GVGAI framework, but we ran into some problems.

We got it running for several episodes, but it ran into a error when the a game was done:

D:\gvgai\venv\Scripts\python.exe "D:/gvgai/1 - gvgai/example/vedio_scripts/main.py"
pygame 2.0.1 (SDL 2.0.14, Python 3.7.9)
Hello from the pygame community. https://www.pygame.org/contribute.html
Games:
    - Name:
    - 2020: golddigger, treasurekeeper, waterpuzzle
    - 2021: bravekeeper, greedymouse, trappedhero
    - Levels: lvl0, lvl1, (2-5)
game Name: bravekeeper
level name: 1
Connecting to host 127.0.0.1 at port 50531 ...
Client connected to server [OK]
frame1, action:0, reward:5, score:5
frame2, action:0, reward:0, score:5
frame3, action:4, reward:0, score:5
frame4, action:2, reward:0, score:5
frame5, action:3, reward:0, score:5
frame6, action:3, reward:0, score:5
frame7, action:4, reward:0, score:5
frame8, action:2, reward:0, score:5
---------------------------
Finish. Final score = 5
Traceback (most recent call last):
  File "D:\Python\Python3.7.9\lib\weakref.py", line 648, in _exitfunc
    f()
  File "D:\Python\Python3.7.9\lib\weakref.py", line 572, in __call__
    return info.func(*info.args, **(info.kwargs or {}))
  File "D:\Python\Python3.7.9\lib\tempfile.py", line 797, in _cleanup
    _shutil.rmtree(name)
  File "D:\Python\Python3.7.9\lib\shutil.py", line 516, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "D:\Python\Python3.7.9\lib\shutil.py", line 395, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "D:\Python\Python3.7.9\lib\shutil.py", line 400, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "D:\Python\Python3.7.9\lib\shutil.py", line 398, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\THYMEN~1\\AppData\\Local\\Temp\\tmp48bujyye\\logs\\clientLog.txt'
Process finished with exit code 0

When looking into the code we found that it had something to do with the game env in python not closing at:

file gvgai\gym_gvgai\envs\gvgai\clients\GVGAI-PythonClient\src\utils\ClientCommGYM.py in the class ClientCommGYM,

And we feel like it should have been closed when calling env.close in the gvgai\gym_gvgai\envs\gvgai_env.py at line 92 in the close function.

Does anyone has suggestions how to fix this?

HcPlu commented 3 years ago

It may be attributed to a long path for the location of GVGAI framework. You can try move the files to the root path.