def join_threads(self, join_main=False): """""" mthread = current_thread() try: for th in thread_enum(): if th is not mthread: th.join() if join_main: mthread.join() except Exception as e: pass
def join_threads(self, join_main=False): """""" mthread = current_thread() try: for th in thread_enum(): if th is not mthread : th.join() if join_main: mthread.join() except Exception as e: pass
def shutdown(): """Shutdown commands""" logger.debug("shutdown() called") try: _ = disable_relay(OUT_PINS['laser']) _ = disable_relay(OUT_PINS['psu']) except AttributeError as ex: logger.exception("Error shutting down GPIO") print("Something went wrong shutting down: {}".format(ex)) print("The GPIO probably never even got initialized...") logger.info("%d thread(s) still alive: %s", active_count(), thread_enum()) if active_count() > 1: logger.critical("CANNOT SHUTDOWN PROPERLY")
def settings_afk(self, event): '''Edit AFK settings''' new_afk = AFKSettings(self.settings["autoafk"], self.settings["afkinterval"]).new_settings if new_afk != None: # Save settings self.settings["autoafk"], self.settings["afkinterval"] = new_afk FILE_WRITE(self.paths["settings"], self.settings) self.autoafk = self.settings["autoafk"] # Start threads if auto-afk if self.settings["autoafk"]: self.afkinit = self.afktimer = self.settings["afkinterval"] if self.thread_afk not in thread_enum(): self.thread_afk = MultiThread(self.afk_countdown) self.thread_afk.daemon = True self.thread_afk.start()
def disconnect(self, event, sendmsg=True): self.quitting = self.disconnected = True # Saving settings if self.settings != self.initsettings: FILE_WRITE(self.paths["settings"], self.settings) # Disable widgets if event: html_online = self.paths["online"] self.chatinput.Disable() self.send.Disable() self.menu_connection_disconnect.Enable(False) self.servers.DeselectAll() FILE_WRITE(html_online, HTML_SESSION) self.userlist.LoadURL(html_online) self.conv_info.SetLabel(self.username + " - disconnected") # Unhooking hooks self.hook_remove() # Sending disconnect if sendmsg: msg = {"datatype": "disconnect"} if self.settings != self.initsettings: msg["settings"] = self.settings self._try_send(msg) # Joining threads threads = thread_enum() for thread in [self.thread_stream, self.thread_recv, self.thread_afk]: if thread in threads: thread.join() # Closing socket self.clientsocket.shutdown(SHUT_RDWR) self.clientsocket.close()
def list_threads(self): """""" print('thread list : ') for th in thread_enum(): print(th)
def list_threads(self): """""" print("thread list : ") for th in thread_enum(): print(th)