Browse Source

init_headers in daemon thread, and fix #1996

283
ThomasV 9 years ago
parent
commit
8249f5ab67
  1. 8
      gui/qt/__init__.py
  2. 1
      gui/qt/installwizard.py
  3. 3
      lib/blockchain.py
  4. 7
      lib/network.py

8
gui/qt/__init__.py

@ -43,9 +43,9 @@ from electrum.paymentrequest import InvoiceStore
from electrum.contacts import Contacts from electrum.contacts import Contacts
from electrum.synchronizer import Synchronizer from electrum.synchronizer import Synchronizer
from electrum.verifier import SPV from electrum.verifier import SPV
from electrum.util import DebugMem from electrum.util import DebugMem, UserCancelled
from electrum.wallet import Abstract_Wallet from electrum.wallet import Abstract_Wallet
from installwizard import InstallWizard from installwizard import InstallWizard, GoBack
try: try:
@ -191,6 +191,10 @@ class ElectrumGui:
def main(self): def main(self):
try: try:
self.init_network() self.init_network()
except UserCancelled:
return
except GoBack:
return
except: except:
traceback.print_exc(file=sys.stdout) traceback.print_exc(file=sys.stdout)
return return

1
gui/qt/installwizard.py

@ -396,6 +396,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
choices = [_("Auto connect"), _("Select server manually")] choices = [_("Auto connect"), _("Select server manually")]
title = _("How do you want to connect to a server? ") title = _("How do you want to connect to a server? ")
clayout = ChoicesLayout(message, choices) clayout = ChoicesLayout(message, choices)
self.back_button.setText(_('Cancel'))
self.set_main_layout(clayout.layout(), title) self.set_main_layout(clayout.layout(), title)
r = clayout.selected_index() r = clayout.selected_index()
if r == 0: if r == 0:

3
lib/blockchain.py

@ -112,7 +112,8 @@ class Blockchain(util.PrintError):
import urllib, socket import urllib, socket
socket.setdefaulttimeout(30) socket.setdefaulttimeout(30)
self.print_error("downloading ", self.headers_url) self.print_error("downloading ", self.headers_url)
urllib.urlretrieve(self.headers_url, filename) urllib.urlretrieve(self.headers_url, filename + '.tmp')
os.rename(filename + '.tmp', filename)
self.print_error("done.") self.print_error("done.")
except Exception: except Exception:
self.print_error("download failed. creating file", filename) self.print_error("download failed. creating file", filename)

7
lib/network.py

@ -813,7 +813,12 @@ class Network(util.DaemonThread):
self.process_responses(interface) self.process_responses(interface)
def run(self): def run(self):
self.blockchain.init() import threading
t = threading.Thread(target = self.blockchain.init)
t.daemon = True
t.start()
while t.isAlive() and self.is_running():
t.join(1)
while self.is_running(): while self.is_running():
self.maintain_sockets() self.maintain_sockets()
self.wait_on_sockets() self.wait_on_sockets()

Loading…
Cancel
Save