<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-

import json


class Worker(object):
    def __init__(self, ):
        pass

    def work(self):
        pass

    def reserve(self):
        pass

    def execute_job(self, job):
        pass<commit_msg>add Worker.work()<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-

import json
import time

import beanstalkc


class Worker(object):
    def __init__(self, host, port, tubes):
        self.host = host
        self.port = port
        self.tubes = tubes

    def work(self):
        while True:
            beanstalk = None
            try:
                if beanstalk:
                    beanstalk.reconnect()
                else:
                    beanstalk = \
                        beanstalkc.Connection(self.host, self.port)
                for tube in self.tubes:
                    beanstalk.watch(tube)
                for tube in beanstalk.watching():
                    if tube not in self.tubes:
                        beanstalk.ignore(tube)

                while True:
                    job = beanstalk.reserve(timeout=10)
                    if not job:
                        time.sleep(2)
                        continue
                    try:
                        self.execute_job(job)
                        job.delete()
                    except Exception, e:
                        job.bury()
            except beanstalkc.SocketError, e:
                time.sleep(2)
                if beanstalk:
                    beanstalk.close()
                beanstalk = None
            time.sleep(2)

    def execute_job(self, job):
        pass
{'fraction_non_alphanumeric': 0.08600847970926712, 'fraction_numerical': 0.004239854633555421, 'mean_word_length': 1.0858585858585859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5580271', 'n_tokens_mistral': 467, 'n_tokens_neox': 410, 'n_words': 101}