def __init__(self, config): window_width = 800 window_height = 600 title = f"Secure Shed Power Console (Core {VERSION})" frame_size = (window_width, window_height) super().__init__(None, title=title, size=frame_size) self._config = config self._curr_page = self.PageSelection.CentralControllerPanel self._status_bar = None self._toolbar = None self._build_status_bar() self._build_toolbar() # Create Sizer for layout self._sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self._sizer) # Central Controller Panel self._central_controller_panel = CentralControllerPanel(self, config) self._sizer.Add(self._central_controller_panel, 1, wx.GROW) # Keypad Controller Panel self._keypad_controller_panel = KeypadControllerPanel(self, config) self._keypad_controller_panel.Hide() self._worker_thread = WorkerThread(self._keypad_controller_panel, self._central_controller_panel) self._worker_thread.start() self.Bind(wx.EVT_CLOSE, self._on_close)
def main(): # global address, client, root_port, processes, outgoing_conns # print(sys.argv) pid = int(sys.argv[1]) # my_pid = pid num_processes = int(sys.argv[2]) own_port = int(sys.argv[3]) print(f"Got pid:{pid}, num_processes:{num_processes}, my port:{own_port}") # Timeouts coordinator_timeout_vote_req = TimeoutThread('coordinator-vote-req') coordinator_timeout_vote_req.start() print("timeout_thead started") m_handler = MasterHandler(pid, globals.address, own_port) globals.outgoing_conns[0] = m_handler # All incoming connections handler = WorkerThread(globals.address, globals.root_port + pid) handler.start() print("worker_thead started") globals.client = Client(pid, num_processes, send_many, coordinator_timeout_vote_req) print("Client has been inited") globals.client.load_state() m_handler.start() print("master_thead started") coordinator_timeout_vote_req.restart()
def init(self): self.src_dir = "/Users/thiruvarasans/Projects/OpenCV/face_filter/src/test/src_images" self.training_images_path = "/Users/thiruvarasans/Projects/OpenCV/face_filter/src/test/training_images" self.dest_dir = "/Users/thiruvarasans/Desktop" self.queue = [] self.testImg = None self._windowIsClosing = 0 self._workerThread = WorkerThread() self._workerThread.start() return self
def trackObjectsThreaded(frame, frameCopy, positions): """Creates thread and lock objects to reliably track the pucks parallelized""" threadList = [] threadLock = threading.Lock() for p in pucks: thread = WorkerThread(p, frame, frameCopy, positions, threadLock) thread.start() threadList.append(thread) for t in threadList: t.join()
def main(): nfuncs = range(len(funcs)) print('***SINGLE THREAD') s = time.time() for i in nfuncs: print(funcs[i](n)) print('TAKES %s' % (time.time() - s)) print("*** MULTIPLE THREAD") threads = [] for i in nfuncs: t = WorkerThread(funcs[i], (n, ), funcs[i].__name__) threads.append(t) s = time.time() for t in threads: t.start() for t in threads: t.join() print(t.get_result()) print('TAKES %s' % (time.time() - s))
def __init__(self): super(MyWindow, self).__init__() self.progressSignal.connect(self.updateProgressSlot) self.initUI() self.__workerThread = WorkerThread(self.progressSignal, self.progressText)
api_key_secret = "BBB" access_token = "CCC" access_token_secret = "DDD" if __name__ == '__main__': if api_key == "AAA" or api_key_secret == "BBB" or access_token == "CCC" or access_token_secret == "DDD": print("Please enter valid twitter api keys and access tokens") sys.exit() account = input( "Please enter twitter account name you want to monitor(exclude @, i.e. @BillGates, you should enter BillGates): " ) if not account: print("Please enter valid account and start application again") sys.exit() new_command = None worker = WorkerThread(account, api_key, api_key_secret, access_token, access_token_secret) while new_command != 'quit': new_command = input("please enter run, dump or quit: ") if new_command == 'run': try: worker.start() except: print(f"Error: unable to start thread.") elif new_command == 'dump': print(f"Currently collected tweets - {total_tweets}") elif new_command == 'quit': worker.stop() print("Quit application.") else: print("Invalid command, please enter run, dump or quit.")