<commit_before># coding: utf-8
import multiprocessing
from time import sleep
import zmq

from django.conf import settings
from django.utils.timezone import now

from parkkeeper.event import emit_event
from parkkeeper import models
from parkworker.const import MONIT_TASK_EVENT


class TaskGenerator(multiprocessing.Process):
    context = None
    socket_pool = None

    def run(self):
        self.cancel_not_started_tasks()

        self.context = zmq.Context()
        self._create_pool()

        print('TaskGenerator started.')

        try:
            while True:
                tasks = models.MonitSchedule.create_tasks()
                for task in tasks:
                    task_json = task.to_json()
                    # task created event
                    emit_event(MONIT_TASK_EVENT, task_json)
                    # send monit tasks for workers
                    monit = models.Monit.objects.get(name=task.monit_name)
                    socket = self._get_socket(monit.worker_type)
                    # print('Send task', task.monit_name, 'on port', monit.worker_type.port)
                    socket.send_json(task_json)
                sleep(1)
        finally:<commit_msg>rework python3-workers for parallel execution of check coroutines<commit_after># coding: utf-8
import multiprocessing
from time import sleep
import zmq

from django.conf import settings
from django.utils.timezone import now

from parkkeeper.event import emit_event
from parkkeeper import models
from parkworker.const import MONIT_TASK_EVENT


class TaskGenerator(multiprocessing.Process):
    context = None
    socket_pool = None

    def run(self):
        self.cancel_not_started_tasks()

        self.context = zmq.Context()
        self._create_pool()

        print('TaskGenerator started.')

        try:
            while True:
                tasks = models.MonitSchedule.create_tasks()
                for task in tasks:
                    task_json = task.to_json()
                    # task created event
                    emit_event(MONIT_TASK_EVENT, task_json)
                    # send monit tasks for workers
                    monit = models.Monit.objects.get(name=task.monit_name)
                    socket = self._get_socket(monit.worker_type)
                    # print('Send task', task.monit_name, 'on port', monit.worker_type.port)
                    socket.send_string(task_json)
                sleep(1)
        finally:
{'fraction_non_alphanumeric': 0.06968215158924206, 'fraction_numerical': 0.002037489812550937, 'mean_word_length': 2.0271270036991367, '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': '6484305', 'n_tokens_mistral': 678, 'n_tokens_neox': 645, 'n_words': 164}