Handle testmode in singleinstance

- it still tried to load pyqt in testmode as singleinstance was only
  checking for daemon and not testmode
This commit is contained in:
Peter Šurda 2018-04-03 22:33:57 +02:00
parent 464b5b4f82
commit 2c44bb4a7c
Signed by: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87

View File

@ -26,7 +26,7 @@ class singleinstance:
self.lockPid = None self.lockPid = None
self.lockfile = os.path.normpath(os.path.join(state.appdata, 'singleton%s.lock' % flavor_id)) self.lockfile = os.path.normpath(os.path.join(state.appdata, 'singleton%s.lock' % flavor_id))
if not self.daemon and not state.curses: if not self.daemon and not state.curses and not state.testmode:
# Tells the already running (if any) application to get focus. # Tells the already running (if any) application to get focus.
import bitmessageqt import bitmessageqt
bitmessageqt.init() bitmessageqt.init()
@ -58,7 +58,7 @@ class singleinstance:
else: # non Windows else: # non Windows
self.fp = open(self.lockfile, 'a+') self.fp = open(self.lockfile, 'a+')
try: try:
if self.daemon and self.lockPid != os.getpid(): if self.daemon and not state.testmode and self.lockPid != os.getpid():
fcntl.lockf(self.fp, fcntl.LOCK_EX) # wait for parent to finish fcntl.lockf(self.fp, fcntl.LOCK_EX) # wait for parent to finish
else: else:
fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB) fcntl.lockf(self.fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
@ -75,7 +75,7 @@ class singleinstance:
def cleanup(self): def cleanup(self):
if not self.initialized: if not self.initialized:
return return
if self.daemon and self.lockPid == os.getpid(): if self.daemon and not state.testmode and self.lockPid == os.getpid():
# these are the two initial forks while daemonizing # these are the two initial forks while daemonizing
try: try:
if sys.platform == 'win32': if sys.platform == 'win32':