示例#1
0
 def __init__(self, n, per_n_seconds=1):
     assert n > 0, 'n must be greater than 0!'
     assert per_n_seconds > 0, 'per_n_seconds must be greater than 0!'
     self.n = n
     self.per_n_seconds = per_n_seconds
     self.semaphore = n
     self.cv = threading.Condition(threading.Lock())
     self.thread = StoppableThread(self.reset)
     return
示例#2
0
	def saytts():
		text = request.args.get("text", None)
		if text is not None:
			Sound.say_tts(text)

			global socialscript_t
			if socialscript_t != None:
				socialscript_t.stop();
			socialscript_t = StoppableThread(target=SocialscriptRun)
			socialscript_t.start();

		return {"status": "success"}
示例#3
0
def start(opsoroapp):
    # Turn servo power off, init servos, update expression
    with Hardware.lock:
        Hardware.servo_disable()
        Hardware.servo_init()
        Hardware.servo_neutral()

    with Expression.lock:
        Expression.set_emotion(valence=0.0, arousal=0.0)
        Expression.update()

    # Start update thread
    global circumplex_t
    circumplex_t = StoppableThread(target=CircumplexLoop)
    circumplex_t.start()
    def process_request(self, request, client_address):
        try:
            self._handler_threads[client_address]
        except KeyError:
            pass
        else:
            print 'Connection error: a connection from', client_address[0]
            print '                  with source port', client_address[1],
            'is already open.'
            return

        t = StoppableThread(target = self.process_request_thread, args = (
            request, client_address))
        self._handler_threads[client_address] = t
        t.daemon = self.daemon_threads
        t.start()
示例#5
0
    def start_listen(self):
        """ Creates and starts a listener thread.

            Raises:
                FBClientError if client is already listening
        """

        try:
            self.thread
            raise FBClientError("Called start_listen when " + \
                    "client is already listening")
        except AttributeError:
            logging.info('Client is listening...')
            self.thread = StoppableThread(name="listen",
                                          target=self._listen_daemon,
                                          args=())
            self.thread.start()
示例#6
0
    def start_script(self, script):
        """
		Start a new script. This method will create a new runtime, pass the
		script to the runtime, and start a thread to continuously call the
		script's loop function. Can only be used if no other script is running.
		"""
        # Check if running
        if self.is_running:
            raise RuntimeError("A script is already running!")

        self._script = script

        callback(self.on_start)()
        self.is_running = True

        # Initialize a new runtime
        self.setup_runtime()

        self.runtime_thread = StoppableThread(target=self._run)
        self.runtime_thread.start()
示例#7
0
def start(opsoroapp):
	# Apply overlay function
	for servo in Expression.servos:
		if servo.pin < 0 or servo.pin > 15:
			continue # Skip invalid pins
		dof_positions[servo.dofname] = 0.0

	# Turn servo power off, init servos, update expression
	with Hardware.lock:
		Hardware.servo_disable()
		Hardware.servo_init()
		Hardware.servo_neutral()

	with Expression.lock:
		Expression.set_emotion(valence=0.0, arousal=0.0)
		Expression.update()

	# Start update thread
	global socialscriptloop_t
	socialscriptloop_t = StoppableThread(target=SocialscriptLoop)
	socialscriptloop_t.start();
示例#8
0
	def play(soundfile):
		soundfiles = []
		filenames = []

		filenames = glob.glob(get_path("../../data/sounds/soundfiles/*.wav"))

		for filename in filenames:
			soundfiles.append(os.path.split(filename)[1])

		if soundfile in soundfiles:
			Sound.play_file(soundfile)

			global socialscript_t
			if socialscript_t != None:
				socialscript_t.stop();
			socialscript_t = StoppableThread(target=SocialscriptRun)
			socialscript_t.start();

			return {"status": "success"}

		else:
			return {"status": "error", "message": "Unknown file."}
示例#9
0
def start(opsoroapp):
    global touch_t

    touch_t = StoppableThread(target=TouchLoop)
    touch_t.start()
示例#10
0
				
			if settings['verbose']:
				print('Restart ! %.3fs after first split.' % timer.elapsed())
			
			comparisons.restart()
			timer.start()	


# ===========================================
#		   FRAME BY FRAME COMPARISON
# ===========================================

queue = Queue()

# prepare the evaluation thread
evaluateThread = StoppableThread(evaluate)

if settings['verbose']:
	print('Starting acquisition.')

while capture.shouldContinue():
	# do not start too many threads
	while queue.qsize() >= 75:
		time.sleep(1e-6)
	
	# start a thread that will capture a frame
	t = Thread(target=getFrame)
	t.start()
	
	# limit fps here
	time.sleep(1/1000)