Skip to content

Bad temp file handling #1270

Closed
Closed

Description

@olivier65

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

Activity

  1. kamusis commented on Jun 8, 2021

    @kamusis

    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.

  2. olivier65 commented on Jun 8, 2021

    @olivier65
    Author

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

  3. j-bennet commented on Jun 11, 2021

    @j-bennet
    Contributor

    I filed an issue in click: pallets/click#1956.

  4. ERYoung11 commented on Sep 2, 2022

    @ERYoung11
    Contributor

    @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?

  5. dbaty commented on Mar 5, 2024

    @dbaty
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions