# This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from typing import Callable, Optional from mephisto.data_model.packet import Packet from mephisto.server.channels.channel import Channel, STATUS_CHECK_TIME import errno import websocket import threading import json import time from mephisto.core.logger_core import get_logger logger = get_logger(name=__name__, verbose=True, level="info") class WebsocketChannel(Channel): """ Channel for communicating with a server via websockets. """ def __init__( self, channel_id: str, on_channel_open: Callable[[str], None], on_catastrophic_disconnect: Callable[[str], None], on_message: Callable[[str, Packet], None], socket_url: str, ): """
) from typing import Dict, Optional, List, Any, TYPE_CHECKING, Iterator import os import time import enum if TYPE_CHECKING: from mephisto.data_model.task import TaskRun from mephisto.data_model.database import MephistoDB import threading from mephisto.core.logger_core import get_logger import types logger = get_logger(name=__name__, verbose=True, level="debug") UNIT_GENERATOR_WAIT_SECONDS = 10 ASSIGNMENT_GENERATOR_WAIT_SECONDS = 0.5 class GeneratorType(enum.Enum): NONE = 0 UNIT = 1 ASSIGNMENT = 2 class TaskLauncher: """ This class is responsible for managing the process of registering and launching units, including the steps for pre-processing