# Path: mlat/server/util.py
# def fuzzy(t):
# def safe_wait(coros_or_futures, **kwargs):
#     def process(self, msg, kwargs):
# def setproctitle(title):
# class TaggingLogger(logging.LoggerAdapter):


import asyncio
import logging
import socket
from mlat.server import util
            self.started = True
            self.reconnect_task = asyncio.async(self.reconnect())

        return util.completed_future

    @asyncio.coroutine
    def reconnect(self):
        while True:
            try:
                reader, writer = yield from asyncio.open_connection(self.host, self.port)
            except socket.error:
                yield from asyncio.sleep(self.reconnect_interval)
                continue

            self.client = self.factory(reader, writer)
            yield from self.client.wait_closed()
            self.client = None
            yield from asyncio.sleep(self.reconnect_interval)

    def close(self):
        if not self.started:
            return

        self.started = False
        self.reconnect_task.cancel()
        if self.client:
            self.client.close()

    @asyncio.coroutine
    def wait_closed(self):

# Path: mlat/server/util.py
# def fuzzy(t):
# def safe_wait(coros_or_futures, **kwargs):
#     def process(self, msg, kwargs):
# def setproctitle(title):
# class TaggingLogger(logging.LoggerAdapter):


# Path: mlat/server/net.py
import asyncio
import logging
import socket
from mlat.server import util

            self.started = True
            self.reconnect_task = asyncio.async(self.reconnect())

        return util.completed_future

    @asyncio.coroutine
    def reconnect(self):
        while True:
            try:
                reader, writer = yield from asyncio.open_connection(self.host, self.port)
            except socket.error:
                yield from asyncio.sleep(self.reconnect_interval)
                continue

            self.client = self.factory(reader, writer)
            yield from self.client.wait_closed()
            self.client = None
            yield from asyncio.sleep(self.reconnect_interval)

    def close(self):
        if not self.started:
            return

        self.started = False
        self.reconnect_task.cancel()
        if self.client:
            self.client.close()

    @asyncio.coroutine
    def wait_closed(self):

        yield from util.safe_wait([self.reconnect_task])