diff --git a/changelog.md b/changelog.md index 23ee3e1a..a9a9ee66 100644 --- a/changelog.md +++ b/changelog.md @@ -6,6 +6,11 @@ Features * Allow styling prompts with HTML-like tags. +Bug Fixes +--------- +* Gracefully fail on background completion-refresh connection issues. + + Documentation --------- * Document the `\g` special command to send a query. diff --git a/mycli/completion_refresher.py b/mycli/completion_refresher.py index 94e6429c..81e74060 100644 --- a/mycli/completion_refresher.py +++ b/mycli/completion_refresher.py @@ -1,6 +1,8 @@ import threading from typing import Callable +import pymysql + from mycli.packages.special.main import COMMANDS from mycli.packages.sqlresult import SQLResult from mycli.sqlcompleter import SQLCompleter @@ -58,22 +60,25 @@ def _bg_refresh( # Create a new sqlexecute method to populate the completions. e = sqlexecute - executor = SQLExecute( - e.dbname, - e.user, - e.password, - e.host, - e.port, - e.socket, - e.character_set, - e.local_infile, - e.ssl, - e.ssh_user, - e.ssh_host, - e.ssh_port, - e.ssh_password, - e.ssh_key_filename, - ) + try: + executor = SQLExecute( + e.dbname, + e.user, + e.password, + e.host, + e.port, + e.socket, + e.character_set, + e.local_infile, + e.ssl, + e.ssh_user, + e.ssh_host, + e.ssh_port, + e.ssh_password, + e.ssh_key_filename, + ) + except pymysql.err.OperationalError: + return # If callbacks is a single function then push it into a list. if callable(callbacks):