def start(self): AVRNode.start(self) self._start_called = 1 self.devices, self.device_addresses = self.findall() if self.running: raise EAlreadyRunning() # Inform in msglog the number of devices on the dallas bus and their addresses (CSCtl81599) if (self.devices == None): no_of_devices = 0 else: no_of_devices = len(self.device_addresses) msglog.log( 'broadway', msglog.types.INFO, 'There are %d devices found on "%s" bus' % (no_of_devices, self.name)) if no_of_devices: addr_str = '' for addr in self.device_addresses: dallas_bus_addr = address_to_asciihex(addr) addr_str = addr_str + ' ' + dallas_bus_addr msglog.log( 'broadway', msglog.types.INFO, 'The device addresses on "%s" bus : %s\n' % (self.name, addr_str)) # Start the thread to read the dallas bus irrespective for whether the devices are # present or not (CSCtl81599) self.running = 1 thread = Thread(name=self.name, target=self._queue_thread, args=()) self.request(self._convert_temperature_sensor_list) thread.start()
def start(self): CompositeNode.start(self) self._set_zip_file() tread = Thread(name="AutoDiscovery",target=self.kick_start_discovery) scheduler.after(2, tread.start) self.ad = AutoDiscovery() self.ad.configure({"parent":self,"name":"AutoDiscover"})
def handle_entry(self, event): self.debug_information('Log entry event caught.') self.debug_information('Going to start export thread.') self._seq_stati.queue_pending(event.seq) thread = Thread(name=self.name, target=self.go, args=(event, )) thread.start() return
def export(self, value): if self.multi_threaded: thread = Thread(name=self.name, target=self._export, args=(value, )) thread.start() else: self._export(value)
def go( self ): # Lock here self._lock.acquire() try: if self.thread and self.thread.isAlive(): # Don't do it! return self.thread = Thread( name = self.name, target = self._complete, args = () ) self.thread.start() finally: self._lock.release()
def go( self ): #spin off a thread to allow _synchronize to run at its own pace # Lock here self._lock.acquire() try: if self.thread and self.thread.isAlive(): # Don't do it! return self.thread = Thread( name = self.name, target = self._complete, args = () ) self.thread.start() finally: self._lock.release()
def start(self): self._test = getattr(Factory(), self.factory)() for mthd_name in self._test.public: try: setattr(self, mthd_name, getattr(self._test, mthd_name)) except: msglog.exception() self._worker_thread = Thread(target=self._work, args=()) self._worker_thread.start() super(DiagIon, self).start() return
def test_release_by_other_thread(self): def acquire_it_elsewhere(lock): lock.acquire() l = allocate1() test_thread = Thread(target=acquire_it_elsewhere,args=(l,)) test_thread.start() while l not in l.locked_list: pause(0.1) try: l.release() except _WrongThreadAssertion: return raise "Failed to detect a release of another thread's acquire."
def test_transport(self): self._listen() thread = Thread(target=self._transporter.transport, args=('Test Data', )) thread.start() conn = self._accept() data = '' more = conn.recv(1024) while more: data += more more = conn.recv(1024) self.failUnless( string.split(data, '\r\n\r\n')[-1] == 'Test Data', 'Transport sent wrong data: %s' % data) conn.send('HTTP/1.1 200 OK\r\n\r\n') conn.close()
def handle_log(self, event): self._event_count += 1 self.debug_information('Log entry event caught.') if self._event_count >= self.log_multiple: self.debug_information('Going to start export thread.') if self._lock.acquire(0): try: thread = Thread(name=self.name, target=self.go, args=(event.values[0], )) thread.start() self._event_count = 0 finally: self._lock.release() else: msglog.log('broadway', msglog.types.WARN, ('Last export still active, ' + 'skipping current request.'))
def handle_log(self, event): self.debug_information('Log export triggered.') self.evt = event #dil - debug value = event.results()[1]['value'] if isinstance(value, Exception): raise value if value: # only export when value is true self.debug_information('Going to start export thread.') if self._lock.acquire(0): try: thread = Thread(name=self.name, target=self.go, args=(time.time(), )) thread.start() finally: self._lock.release() else: msglog.log('broadway', msglog.types.WARN, ('Last export still active, ' + 'skipping current request.'))
def test_cross_thread(self): # @note: This test is relying on the write being large enough to # fill all the OS buffers and block. # # @note: Methinks this test relies on too many side effects... too_big_for_one_write = 1000000 some_of_but_not_all_of_it = 65536 stream = CrossThreadStream() cv = Condition() t1 = Thread(target=_writer, args=(cv, stream, too_big_for_one_write)) cv.acquire() t1.start() # @note: This pause should cause the _writer to block since it is # trying to write too_big_for_one_write. pause(2) data = stream.read(some_of_but_not_all_of_it) count = len(data) self.failUnless( data == 'c' * count and count <= some_of_but_not_all_of_it, 'First read ' + 'failed to return the correct data or returned ' + 'too much data') while count < too_big_for_one_write: data += stream.read(too_big_for_one_write - count) count = len(data) self.failUnless( data == 'c' * too_big_for_one_write, 'Overall stream did not return ' + 'data written to it correctly or the wrong number') self.failUnless( stream.read(100) == '', 'Read did not return empty ' + 'string even though no more data should have been ' + 'waiting and the stream closed') cv.wait() try: self.failIf(_failed, _reason) finally: cv.release()
def _handle_trigger(self, alarm): export_thread = Thread(name=alarm.source.name, target=self._run_exports, args=(alarm, )) export_thread.start()
def load_remote_hosts(self, remote_hosts): thread = Thread(name=self.name, target=self._load_remote_hosts, args=(remote_hosts, )) thread.start()
def start(self): self._start_thread_inst = Thread(name='Vista CPC Startup', target=self._start_thread) self._start_thread_inst.start() self.running = 1 return
def event_handler(self, event): t = Thread(target=self.event_thread, args=(event, )) t.start() return
def start(self): Client.start(self) self._thread = Thread(None, self._poll_alarms) self._go = 1 self._thread.start() return
def respond(server, response='response'): t = Thread(target=_accept_and_respond, args=(server, response)) t.start()
def start(self): ARMNode.start(self) self.running = 1 thread = Thread(name=self.name, target=self._scan_sensors, args=()) thread.start()