Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PGCLI takes a long time to start #1041

Closed
nhumrich opened this issue Apr 22, 2019 · 9 comments
Closed

PGCLI takes a long time to start #1041

nhumrich opened this issue Apr 22, 2019 · 9 comments

Comments

@nhumrich
Copy link

nhumrich commented Apr 22, 2019

Description

Anytime I run pgcli, it takes forever to do anything. It almost seems like it hangs, but if I wait long enough, it eventually works. I initially suspected it was doing something with the keyring because the first time I left it running for a while, the kwallet menu came up. I tried to disable the keyring in the config file and it still takes a long time to load. It even takes a while when connecting to a local database. Everything connects instantly using psql.

Even just running pgcli --version takes forever to load. It somehow looks like its still trying to do something with the keyring, if I ctrl+c in the middle of hanging I get a stack trace that looks like this:

^CTraceback (most recent call last):
  File "/usr/bin/pgcli", line 11, in <module>
    load_entry_point('pgcli==2.1.0', 'console_scripts', 'pgcli')()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2434, in load
    return self.resolve()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2440, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.7/site-packages/pgcli/main.py", line 49, in <module>
    import keyring
  File "/usr/lib/python3.7/site-packages/keyring/__init__.py", line 1, in <module>
    from .core import (
  File "/usr/lib/python3.7/site-packages/keyring/core.py", line 187, in <module>
    init_backend()
  File "/usr/lib/python3.7/site-packages/keyring/core.py", line 91, in init_backend
    keyrings = filter(limit, backend.get_all_keyring())
  File "/usr/lib/python3.7/site-packages/keyring/util/__init__.py", line 21, in wrapper
    func.always_returns = func(*args, **kwargs)
  File "/usr/lib/python3.7/site-packages/keyring/backend.py", line 206, in get_all_keyring
    return list(rings)
  File "/usr/lib/python3.7/site-packages/keyring/util/__init__.py", line 31, in suppress_exceptions
    for callable in callables:
  File "/usr/lib/python3.7/site-packages/keyring/util/properties.py", line 26, in __get__
    return self.fget.__get__(None, owner)()
  File "/usr/lib/python3.7/site-packages/keyring/backend.py", line 63, in viable
    cls.priority
  File "/usr/lib/python3.7/site-packages/keyring/util/properties.py", line 26, in __get__
    return self.fget.__get__(None, owner)()
  File "/usr/lib/python3.7/site-packages/keyring/backends/SecretService.py", line 35, in priority
    list(secretstorage.get_all_collections(bus))
  File "/usr/lib/python3.7/site-packages/secretstorage/collection.py", line 153, in get_all_collections
    for collection_path in service.get_property('Collections'):
  File "/usr/lib/python3.7/site-packages/secretstorage/util.py", line 65, in get_property
    (signature, value), = self.send_and_get_reply(msg)
  File "/usr/lib/python3.7/site-packages/secretstorage/util.py", line 47, in send_and_get_reply
    return self._connection.send_and_get_reply(msg)
  File "/usr/lib/python3.7/site-packages/jeepney/integrate/blocking.py", line 47, in send_and_get_reply
    self.recv_messages()
  File "/usr/lib/python3.7/site-packages/jeepney/integrate/blocking.py", line 35, in recv_messages
    b = self.sock.recv(4096)
KeyboardInterrupt

Your environment

Arch linux, pip installed pgcli.
pip freeze shows:

aiodocker==0.14.0
aiohttp==3.4.4
ansible==2.7.10
anytree==2.6.0
appdirs==1.4.3
Archey3==0.4.1
asn1crypto==0.24.0
async-timeout==3.0.0
atomicwrites==1.2.1
attrs==18.1.0
awscli==1.16.14
awsebcli==3.14.13
backports.csv==1.0.7
bcrypt==3.1.6
Beaker==1.10.1
black==18.6b4
blessed==1.15.0
boto==2.49.0
boto3==1.9.96
botocore==1.12.96
bottle==0.12.16
Brlapi==0.7.0
btrfsutil==1.1.0
CacheControl==0.12.5
cached-property==1.5.1
cachy==0.2.0
cement==2.8.2
certifi==2019.3.9
cffi==1.12.3
chardet==3.0.4
cleo==0.6.8
cli-helpers==1.2.0
Click==7.0
colorama==0.3.9
configobj==5.0.6
cryptography==2.6.1
cycler==0.10.0
decorator==4.3.0
distlib==0.2.8
distro==1.4.0
dnspython==1.15.0
docker==3.7.2
docker-compose==1.24.0
docker-pycreds==0.4.0
dockerpty==0.4.1
docopt==0.6.2
docutils==0.14
dunderdoc==0.3.0
entrypoints==0.3
Flask==1.0.2
future==0.16.0
gi==0.1.0
Glances==3.1.0
gunicorn==19.9.0
h11==0.8.1
html5lib==1.0.1
httpie==1.0.2
httpie-jwt-auth==0.3.0
httplib2==0.12.1
httptools==0.0.13
humanize==0.5.1
idna==2.7
ifaddr==0.1.6
ipython-genutils==0.2.0
isc==2.0
itsdangerous==1.1.0
jedi==0.12.1
jeepney==0.4
Jinja2==2.10.1
jmespath==0.9.3
jsonschema==2.6.0
jupyter-core==4.4.0
keyring==19.0.1
kiwisolver==1.0.1
lensfun==0.3.2
lockfile==0.12.2
louis==3.9.0
lxml==4.3.3
Mako==1.0.9
mallard-ducktype==0.4
Markdown==3.0.1
MarkupSafe==1.1.1
matplotlib==3.0.3
meson==0.50.1
more-itertools==4.3.0
msgpack==0.6.1
multidict==4.3.1
natsort==6.0.0
nbformat==4.4.0
ncmpy==1.5.4
netifaces==0.10.9
numpy==1.16.3
packaging==19.0
paramiko==2.4.2
parso==0.3.1
pastel==0.1.0
pathspec==0.5.9
pep517==0.5.0
pgcli==2.1.0
pgspecial==1.11.5
Pillow==6.0.0
pkginfo==1.4.2
plaid-python==2.3.3
plotly==3.1.0
pluggy==0.7.1
ply==3.11
poetry==0.11.5
powerline-status==2.7
progress==1.5
prompt-toolkit==1.0.15
protobuf==3.7.0
psutil==5.6.1
psycopg2==2.7.7
ptpython==0.41
pudb==2018.1
pulsemixer==1.4.0
pwquality==1.4.0
py==1.6.0
pyasn1==0.4.5
pycairo==1.18.0
pycparser==2.19
pycryptodome==3.8.1
Pygments==2.3.1
PyGObject==3.32.1
pylev==1.3.0
PyNaCl==1.3.0
pyparsing==2.3.1
PyQt5==5.12.1
PyQt5-sip==4.19.16
pyrsistent==0.14.4
pytest==3.8.1
python-dateutil==2.8.0
python-mpd2==1.0.0
pytoml==0.1.20
pytz==2018.9
pyudev==0.21.0.dev20190330
pyxdg==0.26
PyYAML==3.13
pyzmq==18.0.1
rabbitmq-admin==0.2
requests==2.20.1
requests-toolbelt==0.8.0
retrying==1.3.3
rpm==4.14.2.1
rsa==3.4.2
s3transfer==0.2.0
scour==0.37
SecretStorage==3.1.1
semantic-version==2.5.0
setproctitle==1.1.10
shellingham==1.2.6
six==1.11.0
solaar==0.9.2
speedtest-cli==2.1.1
spotify-cli-linux==1.3.0
sqlparse==0.2.4
starlette==0.11.3
tabulate==0.8.3
team==1.0
termcolor==1.1.0
terminaltables==3.1.0
texttable==1.6.1
toml==0.9.4
tomlkit==0.4.4
tqdm==4.24.0
traitlets==4.3.2
twine==1.11.0
ujson==1.35
urllib3==1.24.1
urwid==2.0.1
uvicorn==0.5.2
uvloop==0.12.1
virtualenv==16.1.0
virtualfish==1.0.6
wcwidth==0.1.7
webencodings==0.5.1
websocket-client==0.56.0
websockets==7.0
Werkzeug==0.15.1
xonsh==0.8.12
yarl==1.2.6
zeroconf==0.21.3

PGCLI has version: Version: 2.1.0
arch linux: 5.0.2 kernal

Its also worth noting that for some reason its trying to use kwallet even though I don't use kde. I use i3, with no DM

@j-bennet
Copy link
Contributor

@amjith @zzl0 talking about cli startup time... it looks like keyring was not present in your importtime-waterfall experiment. Was it installed?

@zzl0
Copy link
Contributor

zzl0 commented Apr 23, 2019

@j-bennet I ran pip install pgcli to install pgcli on my Mac laptop last time. I just checked my virtualenv and keyring was not installed. I installed keyring manually and cannot reproduce the problem:

Even just running pgcli --version takes forever to load

@nhumrich can you reproduce the problem on other machines?

@nhumrich
Copy link
Author

@zzl0 I don't have other machines to test on, want to provide one for me ;)

I assume running in a fresh virtual environment or host wont have the same effect, because this isn't happening for everyone. My guess is its probably due to a weird setup where I have kwallet installed, but I don't use KDE.

@zzl0
Copy link
Contributor

zzl0 commented Apr 23, 2019

@nhumrich I don't know the root cause of keyring's long loading problem. Can you just try to run import keyring at your Python shell and see if it hangs there? If yes, then we might be able to get more information if we open an issue on keyring project.

For pgcli, we could change it to load keyring only when keyring is enabled in the config file. @j-bennet @amjith What do you think? If you agree, I can work on this.

@nhumrich
Copy link
Author

yes, just running import keyring does hang for a while. Seems like that is the issue for some reason.

@j-bennet
Copy link
Contributor

For pgcli, we could change it to load keyring only when keyring is enabled in the config file.

@zzl0 I think this would be the best thing we can do on pgcli side. Please go ahead with it.

zzl0 added a commit to zzl0/pgcli that referenced this issue Apr 28, 2019
zzl0 added a commit to zzl0/pgcli that referenced this issue Apr 28, 2019
@zzl0 zzl0 mentioned this issue Apr 28, 2019
2 tasks
zzl0 added a commit to zzl0/pgcli that referenced this issue Apr 28, 2019
zzl0 added a commit to zzl0/pgcli that referenced this issue May 1, 2019
j-bennet pushed a commit that referenced this issue May 1, 2019
@zzl0
Copy link
Contributor

zzl0 commented May 1, 2019

@nhumrich Our fix got merged, pgcli (master branch) should work properly if you disable keyring in your config.

@j-bennet
Copy link
Contributor

j-bennet commented May 5, 2019

Closed via #1046.

@nhumrich
Copy link
Author

nhumrich commented May 7, 2019

works now. Thank you.

@nhumrich nhumrich closed this as completed May 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants