# Path: polyglot/utils.py
# class AsyncFileReader(threading.Thread):
# class LockQueue(Queue):
#     def __init__(self, fd, handler):
#     def run(self):
#     def __init__(self, *args, **kwargs):
#     def put(self, *args, **kwargs):
#     def put_nowait(self, *args, **kwargs):


from collections import defaultdict, OrderedDict
from functools import wraps
from polyglot.utils import AsyncFileReader, Empty, LockQueue
import copy
import json
import logging
import logging.handlers
import sys
import os
import threading
import time
import traceback
import xml.etree.ElementTree as ET
    import yaml
    IO.

    :raises: RuntimeError

    .. decorated
    """
    # pylint: disable=too-many-instance-attributes

    commands = ['config', 'install', 'query', 'status', 'add_all', 'added',
                'removed', 'renamed', 'enabled', 'disabled', 'cmd', 'ping',
                'exit', 'params', 'result', 'statistics']
    """ Commands that may be invoked by Polyglot """
    logger = None
    """
    logger is initialized after the node server wait_for_config completes
    by the setup_log method and the log file is located in the node servers
    sandbox.
    Once wait_for_config is complete, you can call
    `poly.logger.info('This variable is set to %s', variable)`
    """

    def __init__(self):
        # make singleton
        # pylint: disable=global-statement
        global _POLYGLOT_CONNECTION
        if _POLYGLOT_CONNECTION is not None:
            raise RuntimeError('PolyglotConnector may only be created once.')

        # setup properties
        self._outq = LockQueue()

# Path: polyglot/utils.py
# class AsyncFileReader(threading.Thread):
# class LockQueue(Queue):
#     def __init__(self, fd, handler):
#     def run(self):
#     def __init__(self, *args, **kwargs):
#     def put(self, *args, **kwargs):
#     def put_nowait(self, *args, **kwargs):


# Path: polyglot/nodeserver_api.py
from collections import defaultdict, OrderedDict
from functools import wraps
from polyglot.utils import AsyncFileReader, Empty, LockQueue
import copy
import json
import logging
import logging.handlers
import sys
import os
import threading
import time
import traceback
import xml.etree.ElementTree as ET
    import yaml

    IO.

    :raises: RuntimeError

    .. decorated
    """
    # pylint: disable=too-many-instance-attributes

    commands = ['config', 'install', 'query', 'status', 'add_all', 'added',
                'removed', 'renamed', 'enabled', 'disabled', 'cmd', 'ping',
                'exit', 'params', 'result', 'statistics']
    """ Commands that may be invoked by Polyglot """
    logger = None
    """
    logger is initialized after the node server wait_for_config completes
    by the setup_log method and the log file is located in the node servers
    sandbox.
    Once wait_for_config is complete, you can call
    `poly.logger.info('This variable is set to %s', variable)`
    """

    def __init__(self):
        # make singleton
        # pylint: disable=global-statement
        global _POLYGLOT_CONNECTION
        if _POLYGLOT_CONNECTION is not None:
            raise RuntimeError('PolyglotConnector may only be created once.')

        # setup properties
        self._outq = LockQueue()

        self._errq = LockQueue()