mirror of
https://github.com/lilydjwg/fcitx.vim.git
synced 2026-05-11 00:56:07 +08:00
fix reconnect logic
This commit is contained in:
parent
6e53d15569
commit
54febc8b22
2 changed files with 5 additions and 2 deletions
|
|
@ -11,13 +11,15 @@ def may_reconnect(func):
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
try:
|
try:
|
||||||
return func(self, *args, **kwargs)
|
return func(self, *args, **kwargs)
|
||||||
except dbus.exceptions.DBusException:
|
except (dbus.exceptions.DBusException, AttributeError):
|
||||||
self.connect()
|
self.connect()
|
||||||
return wrapped
|
return wrapped
|
||||||
|
|
||||||
class FcitxComm():
|
class FcitxComm():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.connect()
|
# don't connect on start; connect on demand
|
||||||
|
# self.connect()
|
||||||
|
pass
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class FcitxComm(object):
|
||||||
try:
|
try:
|
||||||
return func(*args, **kwargs)
|
return func(*args, **kwargs)
|
||||||
except (socket.error, socket.timeout, struct.error) as e:
|
except (socket.error, socket.timeout, struct.error) as e:
|
||||||
|
self.sock = None
|
||||||
self._error(e)
|
self._error(e)
|
||||||
|
|
||||||
def _status(self):
|
def _status(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue