Added delay to auto announces on start

This commit is contained in:
Mark Qvist 2021-12-11 19:20:34 +01:00
parent 9824a8f7ea
commit b86c811bde
2 changed files with 19 additions and 3 deletions

View file

@ -3,6 +3,7 @@ import io
import sys
import time
import atexit
import threading
import traceback
import contextlib
@ -23,6 +24,8 @@ class NomadNetworkApp:
configdir = os.path.expanduser("~")+"/.nomadnetwork"
START_ANNOUNCE_DELAY = 3
def exit_handler(self):
RNS.log("Nomad Network Client exit handler executing...", RNS.LOG_VERBOSE)
RNS.log("Saving directory...", RNS.LOG_VERBOSE)
@ -208,7 +211,13 @@ class NomadNetworkApp:
self.autoselect_propagation_node()
if self.peer_announce_at_start:
self.announce_now()
def delayed_announce():
time.sleep(NomadNetworkApp.START_ANNOUNCE_DELAY)
self.announce_now()
da_thread = threading.Thread(target=delayed_announce)
da_thread.setDaemon(True)
da_thread.start()
atexit.register(self.exit_handler)
sys.excepthook = self.exception_handler