(self, event, samplequeue)
Continuously monitors the Queue, and writes samples to the log
		file whenever over five are still in the Queue.
Continuously monitors the Queue, and writes samples to the log
		file whenever over five are still in the Queue.
Continuously monitors the Queue and writes samples to the log file whenever over five are still in the Queue .
def _sample_logger(self, event, samplequeue):
		
		"""Continuously monitors the Queue, and writes samples to the log
		file whenever over five are still in the Queue.
		"""
		
		# Create a list to keep track of samples.
		timestamps = []
		samplelist = []
		
		# Continuously run.
		while event.is_set():
			
			# Only process samples if the tracker is recording.
			if self._recording:
				
				# Obtain a new sample if the Queue isn't empty, and lock
				# the Queue while we're using it.
				if not samplequeue.empty():
#				if samplequeue.qsize() > 0:
					# Get the oldest sample in the Queue.
					sample = samplequeue.get()
					# Add the sample to the list.
					timestamps.append(sample[0])
					samplelist.append(sample[1])
					# Store the sample locally, but only if it's not
					# a message.
					if sample[1][0][0] != 'MSG':
						self._latest_sample = sample
				
				# Write the oldest samples from the list, but make sure
				# there are always at least five samples still in the
				# list. We do this, because the sampling happens
				# asynchronously in several parallel processes. This
				# might result in newer samples being processed and
				# becoming available before older samples. Obviously,
				# we want to log the samples in chronological order of
				# obtaining them, not of them becoming available. So
				# we keep a buffer of five samples, which should
				# hopefully be enough to allow slightly older samples
				# to come in.
				while len(timestamps) > 5:
					# Find the oldest timestamp.
					i = numpy.argmin(timestamps)
					t = timestamps.pop(i)
					LR = samplelist.pop(i)
					# Log the sample.
					self._log_sample([t, LR])
			
			# If we're not recording anymore, but there are samples left
			# in the list, then we need to process those first.
			elif not self._recording and len(timestamps) > 0:
				# Empty out the sample buffer.
				while len(timestamps) > 0:
					# Find the oldest timestamp.
					i = numpy.argmin(timestamps)
					t = timestamps.pop(i)
					LR = samplelist.pop(i)
					# Log the sample.
					self._log_sample([t, LR])
			
			# If the tracker is not recording, wait for a bit to avoid
			# wasting processing resources on continuously checking
			# whether the tracker is recording.
			else:
				# Pause for 10 milliseconds.
				time.sleep(0.01)
def _sample_logger ( self , event , samplequeue ) : # Create a list to keep track of samples. timestamps = [ ] samplelist = [ ] # Continuously run. while event . is_set ( ) : # Only process samples if the tracker is recording. if self . _recording : # Obtain a new sample if the Queue isn't empty, and lock # the Queue while we're using it. if not samplequeue . empty ( ) : #				if samplequeue.qsize() > 0: # Get the oldest sample in the Queue. sample = samplequeue . get ( ) # Add the sample to the list. timestamps . append ( sample [ 0 ] ) samplelist . append ( sample [ 1 ] ) # Store the sample locally, but only if it's not # a message. if sample [ 1 ] [ 0 ] [ 0 ] != 'MSG' : self . _latest_sample = sample # Write the oldest samples from the list, but make sure # there are always at least five samples still in the # list. We do this, because the sampling happens # asynchronously in several parallel processes. This # might result in newer samples being processed and # becoming available before older samples. Obviously, # we want to log the samples in chronological order of # obtaining them, not of them becoming available. So # we keep a buffer of five samples, which should # hopefully be enough to allow slightly older samples # to come in. while len ( timestamps ) > 5 : # Find the oldest timestamp. i = numpy . argmin ( timestamps ) t = timestamps . pop ( i ) LR = samplelist . pop ( i ) # Log the sample. self . _log_sample ( [ t , LR ] ) # If we're not recording anymore, but there are samples left # in the list, then we need to process those first. elif not self . _recording and len ( timestamps ) > 0 : # Empty out the sample buffer. while len ( timestamps ) > 0 : # Find the oldest timestamp. i = numpy . argmin ( timestamps ) t = timestamps . pop ( i ) LR = samplelist . pop ( i ) # Log the sample. self . _log_sample ( [ t , LR ] ) # If the tracker is not recording, wait for a bit to avoid # wasting processing resources on continuously checking # whether the tracker is recording. else : # Pause for 10 milliseconds. time . sleep ( 0.01 )