code: def _run_query(self, start_time, end_time, unique_id=None):
      
      # XXX(derek): DEPRECATION WARNING
      # Use of the implicit Kronos client in pycode queries is deprecated
      client = KronosClient(self._app.config['KRONOS_URL'],
                            namespace=self._app.config['KRONOS_NAMESPACE'],
                            blocking=False,
                            sleep_block=0.2)
      locals_dict = {
        'kronos_client': client,
        'events': [],
        'start_time': start_time,
        'end_time': end_time,
      }
      try:
        exec self._query in {}, locals_dict  # No globals.
      except:
        _, exception, tb = sys.exc_info()
        raise PyCodeError(exception, traceback.format_tb(tb))
  
      # Retrieve the `events` variable as computed by the pycode.
      events = locals_dict.get('events', [])
  
      return events
docs: Executes a Python query string and returns events
  
      Acts as a wrapper around exec that injects necessary local variables into
      the scope of the user-provided query blob.
  
      :param start_time: Python datetime to be injected into query
      :param end_time: Python datetime to be injected into query
      :param unique_id: An unused flag that allows the scheduler to hash this
      function uniquely based on its args when it passes through