dexplo/dataframe_image

PermissionError on Windows when using table_conversion='selenium'

Hyperz opened this issue · 1 comments

Hyperz commented

I have a Discord bot running on Windows 10 and Python 3.7 that periodically posts a dataframe image. I create the image using await asyncio.get_running_loop().run_in_executor(None, lambda: dataframe_image.export(df, filename, table_conversion='selenium')). This works fine, but after the 1st export errors start appearing when calling the export function again:

Exception ignored in: <finalize object at 0x2328bc85170; dead>
Traceback (most recent call last):
  File "C:\Development\Python37\lib\weakref.py", line 572, in __call__
    return info.func(*info.args, **(info.kwargs or {}))
  File "C:\Development\Python37\lib\tempfile.py", line 795, in _cleanup
    _shutil.rmtree(name)
  File "C:\Development\Python37\lib\shutil.py", line 516, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Development\Python37\lib\shutil.py", line 400, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Development\Python37\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\\djete\\AppData\\Local\\Temp\\tmpa_fua6qj\\geckodriver.log'

The error doesn't cause any actual problems as far as I can tell, but still. Looking at the code I'm guessing it's due to temp_dir_obj never actually getting cleaned up in the SeleniumScreenshot class? I'm using dataframe-image==0.1.13.

Can you provide a piece of code for me to reproduce the problem?