mycli icon indicating copy to clipboard operation
mycli copied to clipboard

Startup error

Open MrRedstoner opened this issue 6 years ago • 12 comments

I just installed MyCLI on a CentOS 7 machine, using pip.

Itermittently I get

Exception in thread completion_refresh:
Traceback (most recent call last):
  File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib64/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/site-packages/mycli/completion_refresher.py", line 77, in _bg_refresh
    callback(completer)                                                                                                                                                 
  File "/usr/local/lib/python3.6/site-packages/mycli/main.py", line 865, in _on_completions_refreshed
    self.prompt_app.app.invalidate()
  File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 468, in invalidate
    schedule_redraw()
  File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 451, in schedule_redraw
    redraw, max_postpone_time=self.max_render_postpone_time, loop=self.loop
  File "/usr/local/lib/python3.6/site-packages/prompt_toolkit/eventloop/utils.py", line 57, in call_soon_threadsafe
    loop2 = loop or get_event_loop()
  File "/usr/lib64/python3.6/asyncio/events.py", line 694, in get_event_loop
    return get_event_loop_policy().get_event_loop()
  File "/usr/lib64/python3.6/asyncio/events.py", line 602, in get_event_loop
    % threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'completion_refresh'.

on startup. I can end the session using Ctrl+D, the Goodbye! at the end does show up.

It seems to happen <50% of the time so far.

I did some changes before the issue first happened, I set up MySQL stored credentials using mysql_config_editor and changed the .myclirc to default to vi mode. I'm starting mycli with -h localhost, otherwise it first tries and fails to connect by socket (2003, "Can't connect ...").

Versions printed after succesfull startup: MySQL 8.0.16 MyCLI 1.20.1

MrRedstoner avatar Nov 29 '19 10:11 MrRedstoner

+1 in python 3.7

tt67wq avatar Dec 03 '19 03:12 tt67wq

That's because the new version 3 of prompt-toolkit has been published on pypi. MyCLI does not support it yet, but pulls the latest version during install. We'll fix the install script, in the meantime you can just downgrade the prompt-toolkit in the environment from which you call mycli:

pip install "prompt-toolkit<3.0.0"

python >= 3.6 is affected

gfrlv avatar Dec 03 '19 10:12 gfrlv

After the downgrade I tried startup 10 times in a row. Not a single failure has occurred, I'm assuming it is indeed completely resolved. Shall I close the issue or do you manage that yourselves?

MrRedstoner avatar Dec 04 '19 18:12 MrRedstoner

Let's leave it open until the next release. Thanks again for reporting!

gfrlv avatar Dec 05 '19 03:12 gfrlv

No problem. Thanks a bunch for resolving it quickly.

MrRedstoner avatar Dec 05 '19 06:12 MrRedstoner

I just wanted to add that if you use pipx: pipx install mycli pipx inject mycli "prompt-toolkit<3.0.0" Seems to work.

Before i got it working I noticed that if i used the root user I did not get the Exception, only on other users.

sonnerberg avatar Jan 17 '20 19:01 sonnerberg

I get the same error. Is there any new solution?

wsh3776 avatar Aug 09 '20 01:08 wsh3776

@meteorsh I take it you have downgraded to prompt_toolkit lower than 3.0.0?

MrRedstoner avatar Aug 09 '20 08:08 MrRedstoner

@meteorsh I take it you have downgraded to prompt_toolkit lower than 3.0.0?

Hi, I have updated the prompt_toolkit bigger than 3.0.0, as follows.

image

And after I use mycli several times, I will get the error. Sometimes it works, sometimes not. Very strange!

image

wsh3776 avatar Aug 09 '20 08:08 wsh3776

@meteorsh Yes, that's because you need prompt_toolkit < 3.0.0, in other words you need some version 2.x.y

MrRedstoner avatar Aug 09 '20 09:08 MrRedstoner

@meteorsh Yes, that's because you need prompt_toolkit < 3.0.0, in other words you need some version 2.x.y

I tried it, but got this error.

image

wsh3776 avatar Aug 09 '20 15:08 wsh3776

Interesting, as you can see from my original description I was running mycli 1.20.1 at the time. Until you get an official response it might be worth trying to downgrade to that as well as prompt toolkit and see if it help.

MrRedstoner avatar Aug 09 '20 15:08 MrRedstoner