forked from LBRYCommunity/lbry-sdk
setup Commands class on run, instead of on initialization
This commit is contained in:
parent
7d02e7d370
commit
1690e71ad1
1 changed files with 5 additions and 5 deletions
|
@ -771,7 +771,6 @@ class LBRYumWallet(Wallet):
|
||||||
self._config = config
|
self._config = config
|
||||||
self.network = None
|
self.network = None
|
||||||
self.wallet = None
|
self.wallet = None
|
||||||
self.cmd_runner = None
|
|
||||||
self.first_run = False
|
self.first_run = False
|
||||||
self.printed_retrieving_headers = False
|
self.printed_retrieving_headers = False
|
||||||
self._start_check = None
|
self._start_check = None
|
||||||
|
@ -814,7 +813,6 @@ class LBRYumWallet(Wallet):
|
||||||
d.addCallback(lambda _: self._start_check.start(.1))
|
d.addCallback(lambda _: self._start_check.start(.1))
|
||||||
d.addCallback(lambda _: network_start_d)
|
d.addCallback(lambda _: network_start_d)
|
||||||
d.addCallback(lambda _: self._load_blockchain())
|
d.addCallback(lambda _: self._load_blockchain())
|
||||||
d.addCallback(lambda _: self._get_cmd_runner())
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _stop(self):
|
def _stop(self):
|
||||||
|
@ -908,21 +906,23 @@ class LBRYumWallet(Wallet):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _get_cmd_runner(self):
|
def _get_cmd_runner(self):
|
||||||
self.cmd_runner = Commands(self.config, self.wallet, self.network)
|
return Commands(self.config, self.wallet, self.network)
|
||||||
|
|
||||||
# run commands as a defer.succeed,
|
# run commands as a defer.succeed,
|
||||||
# lbryum commands should be run this way , unless if the command
|
# lbryum commands should be run this way , unless if the command
|
||||||
# only makes a lbrum server query, use _run_cmd_as_defer_to_thread()
|
# only makes a lbrum server query, use _run_cmd_as_defer_to_thread()
|
||||||
def _run_cmd_as_defer_succeed(self, command_name, *args):
|
def _run_cmd_as_defer_succeed(self, command_name, *args):
|
||||||
|
cmd_runner = self._get_cmd_runner()
|
||||||
cmd = known_commands[command_name]
|
cmd = known_commands[command_name]
|
||||||
func = getattr(self.cmd_runner, cmd.name)
|
func = getattr(cmd_runner, cmd.name)
|
||||||
return defer.succeed(func(*args))
|
return defer.succeed(func(*args))
|
||||||
|
|
||||||
# run commands as a deferToThread, lbryum commands that only make
|
# run commands as a deferToThread, lbryum commands that only make
|
||||||
# queries to lbryum server should be run this way
|
# queries to lbryum server should be run this way
|
||||||
def _run_cmd_as_defer_to_thread(self, command_name, *args):
|
def _run_cmd_as_defer_to_thread(self, command_name, *args):
|
||||||
|
cmd_runner = self._get_cmd_runner()
|
||||||
cmd = known_commands[command_name]
|
cmd = known_commands[command_name]
|
||||||
func = getattr(self.cmd_runner, cmd.name)
|
func = getattr(cmd_runner, cmd.name)
|
||||||
return threads.deferToThread(func, *args)
|
return threads.deferToThread(func, *args)
|
||||||
|
|
||||||
def get_balance(self):
|
def get_balance(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue