Skip to content
Snippets Groups Projects
Commit cd680063 authored by inso's avatar inso
Browse files

Run sakia in parallel for multi currency

parent 386b8f62
No related branches found
No related tags found
No related merge requests found
......@@ -88,9 +88,7 @@ class Application(QObject):
app_data = AppDataFile.in_config_path(options.config_path).load_or_init()
app = cls(qapp, loop, options, app_data, None, None, options.currency, None)
#app.set_proxy()
app.get_last_version()
app.load_profile(options.profile)
app.start_coroutines()
app.documents_service = DocumentsService.instanciate(app)
app.switch_language()
return app
......
import re
import hashlib
from PyQt5.QtCore import QSharedMemory
from PyQt5.QtWidgets import QApplication
......@@ -17,8 +18,11 @@ def detect_non_printable(data):
return True
def single_instance_lock():
sharedMemory = QSharedMemory("77rWEV37vupNhQs6ktDREthqSciyV77OYrqPBSwV755JFIhl9iOywB7G5DkAKU8Y")
def single_instance_lock(currency):
key = hashlib.sha256(currency.encode('utf-8')
+ "77rWEV37vupNhQs6ktDREthqSciyV77OYrqPBSwV755JFIhl9iOywB7G5DkAKU8Y".encode('utf-8'))\
.hexdigest()
sharedMemory = QSharedMemory(key)
if sharedMemory.attach(QSharedMemory.ReadOnly):
sharedMemory.detach()
return None
......
......@@ -82,15 +82,6 @@ if __name__ == '__main__':
signal.signal(signal.SIGINT, signal.SIG_DFL)
sakia = QApplication(sys.argv)
lock = single_instance_lock()
if not lock:
lock = single_instance_lock()
if not lock:
QMessageBox.critical(None, "Sakia",
"Sakia is already running.")
sys.exit(1)
sys.excepthook = exception_handler
sakia.setStyle('Fusion')
......@@ -100,7 +91,17 @@ if __name__ == '__main__':
with loop:
app = Application.startup(sys.argv, sakia, loop)
lock = single_instance_lock(app.currency)
if not lock:
lock = single_instance_lock(app.currency)
if not lock:
QMessageBox.critical(None, "Sakia",
"Sakia is already running.")
sys.exit(1)
app.start_coroutines()
app.get_last_version()
keep_trying = True
while not app.blockchain_service.initialized():
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment