def insert_seeds(self):
print "[ +D+ ] - Begin seed insertion for minimization"
bs = beanstalkc.Connection(host='127.0.0.1', port=11300)
bs.use('min-queue')
try:
self.c.execute('''SELECT seed_name FROM results''')
seeds = self.c.fetchall()
for seed_name in seeds:
if not self.is_minimized(seed_name):
with open(os.path.join(self.seed_dir, seed_name), 'rb') as d:
seed_data = d.read()
data = {
'name': seed_name,
'data': seed_data
}
seed_pack = msgpack.packb(data, use_bin_type=True)
while True:
if bs.stats_tube('minimize')['current-jobs-ready'] < 20:
print "[ +D+ ] - Pushing seed: %s" % seed_name
# Allow 4 hours for minimization - hackish
# Fix this later by touching the job after each successful action
bs.put(seed_pack, ttr=14400)
break
else:
sleep(1)
finally:
bs.close()
self.sql.close()
print "[ +D+ ] - All seeds inserted for minimization"
评论列表
文章目录