<commit_before>package thepieuvre.core

import grails.converters.JSON
import org.apache.log4j.Logger
import redis.clients.jedis.Jedis

class FeedParser implements Runnable {
	private static final Logger log = Logger.getLogger(FeedParser.class)

 	def grailsApplication

	FeedParser(def grailsApplication) {
		this.grailsApplication = grailsApplication
	}

	@Override
	void run() {
		while(true) {
			Feed feed= null
			grailsApplication.mainContext.redisService.withRedis { Jedis redis ->
				while(true) {
					try {
						def msg = redis.blpop(60000, 'queue:feedparser')
						if (msg) {
							log.info "Getting message from queue:feedparser"
							def decoded = JSON.parse(msg[1])
							feed= Feed.get(decoded.id as Long)
							log.debug "Updating feed $feed"
							if (feed) {
								grailsApplication.mainContext.feedService.update(feed, decoded)
							} else {
								log.warn "Cannot update $feed with $decoded"
							}
						} else {
							continue
						}
					} catch (Exception e) {
						log.error "A problem occured with a feed to update", e
						continue
					} 
				}
			}
			continue
		}
	}
}
<commit_msg>Lower waiting time for feed parser queue<commit_after>package thepieuvre.core

import grails.converters.JSON
import org.apache.log4j.Logger
import redis.clients.jedis.Jedis

class FeedParser implements Runnable {
	private static final Logger log = Logger.getLogger(FeedParser.class)

 	def grailsApplication

	FeedParser(def grailsApplication) {
		this.grailsApplication = grailsApplication
	}

	@Override
	void run() {
		while(true) {
			Feed feed= null
			grailsApplication.mainContext.redisService.withRedis { Jedis redis ->
				while(true) {
					try {
						def msg = redis.blpop(1000, 'queue:feedparser')
						if (msg) {
							log.info "Getting message from queue:feedparser"
							def decoded = JSON.parse(msg[1])
							feed= Feed.get(decoded.id as Long)
							log.debug "Updating feed $feed"
							if (feed) {
								grailsApplication.mainContext.feedService.update(feed, decoded)
							} else {
								log.warn "Cannot update $feed with $decoded"
							}
						} else {
							continue
						}
					} catch (Exception e) {
						log.error "A problem occured with a feed to update", e
						continue
					} 
				}
			}
			continue
		}
	}
}

{'fraction_non_alphanumeric': 0.0925764192139738, 'fraction_numerical': 0.005676855895196507, 'mean_word_length': 2.713128038897893, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '665082', 'n_tokens_mistral': 986, 'n_tokens_neox': 717, 'n_words': 180}