MCPcopy
hub / github.com/dbcli/pgcli / refresh

Method refresh

pgcli/completion_refresher.py:15–43  ·  view source on GitHub ↗

Creates a PGCompleter object and populates it with the relevant completion suggestions in a background thread. executor - PGExecute object, used to extract the credentials to connect to the database. special - PGSpecial object used for creating a

(self, executor, special, callbacks, history=None, settings=None)

Source from the content-addressed store, hash-verified

13 self._restart_refresh = threading.Event()
14
15 def refresh(self, executor, special, callbacks, history=None, settings=None):
16 """
17 Creates a PGCompleter object and populates it with the relevant
18 completion suggestions in a background thread.
19
20 executor - PGExecute object, used to extract the credentials to connect
21 to the database.
22 special - PGSpecial object used for creating a new completion object.
23 settings - dict of settings for completer object
24 callbacks - A function or a list of functions to call after the thread
25 has completed the refresh. The newly created completion
26 object will be passed in as an argument to each callback.
27 """
28 if executor.is_virtual_database():
29 # do nothing
30 return [(None, None, None, "Auto-completion refresh can't be started.")]
31
32 if self.is_refreshing():
33 self._restart_refresh.set()
34 return [(None, None, None, "Auto-completion refresh restarted.")]
35 else:
36 self._completer_thread = threading.Thread(
37 target=self._bg_refresh,
38 args=(executor, special, callbacks, history, settings),
39 name="completion_refresh",
40 )
41 self._completer_thread.daemon = True
42 self._completer_thread.start()
43 return [(None, None, None, "Auto-completion refresh started in the background.")]
44
45 def is_refreshing(self):
46 return self._completer_thread and self._completer_thread.is_alive()

Callers 4

refresh_completionsMethod · 0.80
test_refresh_called_onceFunction · 0.80

Calls 2

is_refreshingMethod · 0.95
is_virtual_databaseMethod · 0.80

Tested by 3

test_refresh_called_onceFunction · 0.64