Esempio n. 1
0
def process_gtest_results(buildbot_root, builder, step_name, time_finished,
                          results):
    # _processing is global but we're not modifying it.
    # global _processing

    with _lock:
        logging.debug('stats before: %d' % len(_stats.keys()))
        for fullname, result in results.items():
            weekly_timestamp = (
                time_finished.date() -
                datetime.timedelta(days=time_finished.weekday()))
            key_name = '%s-%s-%s-%s-%s' % (buildbot_root, builder, step_name,
                                           fullname, weekly_timestamp)
            if key_name not in _stats:
                _stats[key_name] = {
                    'buildbot_root': buildbot_root,
                    'builder': builder,
                    'step_name': step_name,
                    'fullname': fullname,
                    'weekly_timestamp': weekly_timestamp,
                    'results': [],
                }
                _queue.append(key_name)
            _stats[key_name]['results'].append(result)

        if not _processing and len(_stats) > QUEUE_THRESHOLD:
            background_thread.start_new_background_thread(
                flush_summaries_to_datastore, [])
Esempio n. 2
0
def process_gtest_results(buildbot_root,
                          builder,
                          step_name,
                          time_finished,
                          results):
  # _processing is global but we're not modifying it.
  # global _processing

  with _lock:
    logging.debug('stats before: %d' % len(_stats.keys()))
    for fullname, result in results.items():
      weekly_timestamp = (time_finished.date() -
                          datetime.timedelta(days=time_finished.weekday()))
      key_name='%s-%s-%s-%s-%s' % (buildbot_root,
                                   builder,
                                   step_name,
                                   fullname,
                                   weekly_timestamp)
      if key_name not in _stats:
        _stats[key_name] = {
          'buildbot_root': buildbot_root,
          'builder': builder,
          'step_name': step_name,
          'fullname': fullname,
          'weekly_timestamp': weekly_timestamp,
          'results': [],
        }
        _queue.append(key_name)
      _stats[key_name]['results'].append(result)

    if not _processing and len(_stats) > QUEUE_THRESHOLD:
      background_thread.start_new_background_thread(
          flush_summaries_to_datastore, [])
Esempio n. 3
0
    def get(self):
        """
        Demonstrates using a background thread to change the global
        val from 'Dog' to 'Cat'

        The auto GET parameter determines whether to start the thread
        automatically or manually
        """
        auto = self.request.get('auto')

        # [START gae_runtime]
        # sample function to run in a background thread
        def change_val(arg):
            global val
            val = arg

        if auto:
            # Start the new thread in one command
            background_thread.start_new_background_thread(change_val, ['Cat'])
        else:
            # create a new thread and start it
            t = background_thread.BackgroundThread(target=change_val,
                                                   args=['Cat'])
            t.start()
        # [END gae_runtime]

        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Done')
Esempio n. 4
0
    def get(self):
        """
        Demonstrates using a background thread to change the global
        val from 'Dog' to 'Cat'

        The auto GET parameter determines whether to start the thread
        automatically or manually
        """
        auto = self.request.get('auto')

        # [START background-start]
        # sample function to run in a background thread
        def change_val(arg):
            global val
            val = arg

        if auto:
            # Start the new thread in one command
            background_thread.start_new_background_thread(change_val, ['Cat'])
        else:
            # create a new thread and start it
            t = background_thread.BackgroundThread(
                target=change_val, args=['Cat'])
            t.start()
        # [END background-start]

        self.response.headers['Content-Type'] = 'text/plain'
        self.response.write('Done')
Esempio n. 5
0
def combine_employees():
    old_username, new_username = request.args['old'], request.args['new']
    if not old_username:
        return Response(response='{} is not a valid username'.format(old_username), status=400)
    elif not new_username:
        return Response(response='{} is not a valid username'.format(new_username), status=400)

    background_thread.start_new_background_thread(logic.employee.combine_employees, [old_username, new_username])
    return Response(status=200)
Esempio n. 6
0
    def _start(self):
        try:
            delay = int(flask.request.args.get('delay', None))
        except (TypeError, ValueError):
            delay = None

        for i in xrange(self.workers_per_spawn):
            start_new_background_thread(self._pull, (
                flask.current_app._get_current_object(),
                delay,))

        return "Started {} workers".format(self.workers_per_spawn)
Esempio n. 7
0
 def post(self):
     '''
     '''
     tid = background_thread.start_new_background_thread(self.__submit_new_batch_job, [])
     self.response.headers['Content-Type'] = 'application/json'
     return self.response.write(json.dumps({
         "success": True
     }))
Esempio n. 8
0
  def get(self):
    runtime.set_shutdown_hook(shutdown_hook)

    global streams, streams_lock, update_thread
    with streams_lock:
      streams = {}
      if update_thread is None:
        update_thread = background_thread.start_new_background_thread(
          update_streams, [])
    def post(self):
        req_agent = self.request.get('agent')
        self.agent = pickle.loads(str(req_agent))
        self.agent_type = self.agent.AGENT_NAME

        req_parameters = self.request.get('parameters')
        self.parameters = pickle.loads(str(req_parameters))

        self.is_start = False
        self.thread_id = background_thread.start_new_background_thread(
            self.begin, [])
        logging.info(
            'Started a background thread to synchronize db. id: {0} agent: {1} parameters : {2}'
            .format(self.thread_id, self.agent_type, self.parameters))
        return
Esempio n. 10
0
    def post(self):
        req_agent = self.request.get("agent")
        self.agent = pickle.loads(str(req_agent))
        self.agent_type = self.agent.AGENT_NAME

        req_parameters = self.request.get("parameters")
        self.parameters = pickle.loads(str(req_parameters))

        self.is_start = False
        self.thread_id = background_thread.start_new_background_thread(self.begin, [])
        logging.info(
            "Started a background thread to synchronize db. id: {0} agent: {1} parameters : {2}".format(
                self.thread_id, self.agent_type, self.parameters
            )
        )
        return
Esempio n. 11
0
 def post(self):
   if not users.is_current_user_admin():
     self.abort(401, 'Must be an admin to start a mapreduce.')    
   background_thread.start_new_background_thread(run_attempt, [])
   self.redirect(self.request.route.build(self.request, [], {}))
Esempio n. 12
0
 def __init__(self, t, all_t, x, y):
     super(Farm, self).__init__(self, t, all_t, x, y, 100, "cow", 1)
     p = background_thread.start_new_background_thread(
         target=self.gatherResource)
Esempio n. 13
0
	def get(self):
		background_thread.start_new_background_thread(updateDistricts, [])
		self.response.out.write('Updated Districts')
Esempio n. 14
0
def rebuild_love_count():
    background_thread.start_new_background_thread(logic.love_count.rebuild_love_count, [])
    return Response(status=200)
Esempio n. 15
0
 def post(self):
     if not users.is_current_user_admin():
         self.abort(401, 'Must be an admin to start a mapreduce.')
     background_thread.start_new_background_thread(run_attempt, [])
     self.redirect(self.request.route.build(self.request, [], {}))
 def insert_row(self, data_set, table, data):
     background_thread.start_new_background_thread(self._insert_row, [data_set, table, data])
Esempio n. 17
0
	def get(self):
		background_thread.start_new_background_thread(timer_loop, [])
Esempio n. 18
0
 def _start_next_timer(self):
     time_left = (PlaylistEntry.get(self.entries[0]).duration - 
         self._get_seek_time() - CROSSFADE_DURATION_SECONDS)
     play_timer = threading.Timer(time_left, self._next)
     _play_timers[self.key().name()] = play_timer
     background_thread.start_new_background_thread(play_timer.start, [])
Esempio n. 19
0
 def post(self):
   tid = background_thread.start_new_background_thread(sendMailSummary, [])
Esempio n. 20
0
 def get(self):
     #deferred.defer(TreeScrapper.scrape_to_db)
     background_thread.start_new_background_thread(TreeScrapper.scrape_to_db, [])
     self.response.write('Running!')
Esempio n. 21
0
def call_background_thread(target, args, kwargs=None):
    background_thread.start_new_background_thread(target=self.__spawn_vms, args=[agent, num_vms, parameters, reservation_id])