def callback_new_mot(self, json_body): logging.debug("[received] new MoT segments %r" % json_body) # Extract the batch ID and the list mo MoT segments froim the json! try: batch_id = str(uuid.uuid4()) if not json_body['mot_segments']: logging.debug( 'mot_segments is empty. Skipping schedule matching.') return [] list_mot_id, loc_bounds = self.geo_valid(json_body['mot_segments']) if not list_mot_id: logging.debug('no mot id. Skipping schedule matching.') return [] except Exception as e: logging.error(e) err = 'Unable to parse JSON into a batch id and list of mot ids' logging.error(err) # we are going to write the error to a separate queue return [] b = Batch(batch_id, list_mot_id, loc_bounds, CONFIG, DB) b.init_trips() # we have to clear out the DB attr since it can't be pickled b.DB = None # now we are doing this in redis self.redis_client.upload_to_redis(batch_id, { 'status': 0, 'batch': pickle.dumps(b) }) # send reqs b.send_trip_requests() # Empty list when not sending any message out otherwise rabbit consumer doesn't like it return []