Browse Source

init_headers in daemon thread, and fix #1996

283
ThomasV 8 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.synchronizer import Synchronizer
from electrum.verifier import SPV
from electrum.util import DebugMem
from electrum.util import DebugMem, UserCancelled
from electrum.wallet import Abstract_Wallet
from installwizard import InstallWizard
from installwizard import InstallWizard, GoBack
try:
@ -191,6 +191,10 @@ class ElectrumGui:
def main(self):
try:
self.init_network()
except UserCancelled:
return
except GoBack:
return
except:
traceback.print_exc(file=sys.stdout)
return

1
gui/qt/installwizard.py

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

3
lib/blockchain.py

@ -112,7 +112,8 @@ class Blockchain(util.PrintError):
import urllib, socket
socket.setdefaulttimeout(30)
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.")
except Exception:
self.print_error("download failed. creating file", filename)

7
lib/network.py

@ -813,7 +813,12 @@ class Network(util.DaemonThread):
self.process_responses(interface)
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():
self.maintain_sockets()
self.wait_on_sockets()

Loading…
Cancel
Save