Startup error
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
+1 in python 3.7
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
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?
Let's leave it open until the next release. Thanks again for reporting!
No problem. Thanks a bunch for resolving it quickly.
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.
I get the same error. Is there any new solution?
@meteorsh I take it you have downgraded to prompt_toolkit lower than 3.0.0?
@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.

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

@meteorsh Yes, that's because you need prompt_toolkit < 3.0.0, in other words you need some version 2.x.y
@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.

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.