pgcli icon indicating copy to clipboard operation
pgcli copied to clipboard

Bad temp file handling

Open olivier65 opened this issue 3 years ago • 4 comments

Description

  1. invoke pgcli
  2. \l
  3. q
  4. crash:
Traceback (most recent call last):
  File "C:\Python\3.8\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python\3.8\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "<redacted>\venv\Scripts\pgcli.exe\__main__.py", line 7, in <module>
  File "<redacted>\venv\lib\site-packages\click\core.py", line 1134, in __call__
    return self.main(*args, **kwargs)
  File "<redacted>\venv\lib\site-packages\click\core.py", line 1059, in main
    rv = self.invoke(ctx)
  File "<redacted>\venv\lib\site-packages\click\core.py", line 1401, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "<redacted>\venv\lib\site-packages\click\core.py", line 767, in invoke
    return __callback(*args, **kwargs)
  File "<redacted>\venv\lib\site-packages\pgcli\main.py", line 1336, in cli
    pgcli.run_cli()
  File "<redacted>\venv\lib\site-packages\pgcli\main.py", line 765, in run_cli
    query = self.execute_command(text)
  File "<redacted>\venv\lib\site-packages\pgcli\main.py", line 684, in execute_command
    self.echo_via_pager("\n".join(output))
  File "<redacted>\venv\lib\site-packages\pgcli\main.py", line 1085, in echo_via_pager
    click.echo_via_pager(text, color=color)
  File "<redacted>\venv\lib\site-packages\click\termui.py", line 302, in echo_via_pager
    return pager(itertools.chain(text_generator, "\n"), color)
  File "<redacted>\venv\lib\site-packages\click\_termui_impl.py", line 357, in pager
    return _tempfilepager(generator, "more <", color)
  File "<redacted>\venv\lib\site-packages\click\_termui_impl.py", line 440, in _tempfilepager
    os.unlink(filename)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: '%TEMP%\\tmp_cpxsj61'

Happens 100% reliably.

Your environment

Windows 10 version 21H1 python 3.8.10 python packages (in a clean venv in which pgcli is the only package installed manually):

cli-helpers==2.1.0
click==8.0.0
colorama==0.4.4
configobj==5.0.6
pendulum==2.1.2
pgcli==3.1.0
pgspecial==1.12.1
prompt-toolkit==3.0.18
psycopg2==2.8.6
Pygments==2.9.0
python-dateutil==2.8.1
pytzdata==2020.1
setproctitle==1.2.2
six==1.16.0
sqlparse==0.4.1
tabulate==0.8.9
terminaltables==3.1.0
wcwidth==0.2.5

olivier65 avatar May 19 '21 19:05 olivier65

Try to downgrade click 8.0.0 to click 7.1.2. python3 -m pip install click==7.1.2 then rerun pgcli, issue should be resolved.

kamusis avatar Jun 08 '21 13:06 kamusis

Yes, I had already done that. But please update your setup.py, too.

olivier65 avatar Jun 08 '21 14:06 olivier65

I filed an issue in click: https://github.com/pallets/click/issues/1956.

j-bennet avatar Jun 11 '21 16:06 j-bennet

@j-bennet @olivier65 This appears to have been fixed by Click Pull 2036 I have a Windows environment with the latest build and can't reproduce this. @olivier65 Can you confirm?

ERYoung11 avatar Sep 02 '22 02:09 ERYoung11

Thanks for trying to reproduce, @ERYoung11. Since we have no news from the original reporter on this 3-year old issue, I am closing this.

dbaty avatar Mar 05 '24 09:03 dbaty