# Path: pyftpdlib/_compat.py
# def callable(obj):
#     for klass in type(obj).__mro__:
#         if "__call__" in klass.__dict__:
#             return True
#     return False
# 
# Path: pyftpdlib/log.py
# def config_logging(level=LEVEL, prefix=PREFIX, other_loggers=None):
#     # Little speed up
#     if "(process)" not in prefix:
#         logging.logProcesses = False
#     if "%(processName)s" not in prefix:
#         logging.logMultiprocessing = False
#     if "%(thread)d" not in prefix and "%(threadName)s" not in prefix:
#         logging.logThreads = False
#     handler = logging.StreamHandler()
#     formatter = LogFormatter()
#     formatter.PREFIX = prefix
#     handler.setFormatter(formatter)
#     loggers = [logging.getLogger('pyftpdlib')]
#     if other_loggers is not None:
#         loggers.extend(other_loggers)
#     for logger in loggers:
#         logger.setLevel(level)
#         logger.addHandler(handler)
# 
# Path: pyftpdlib/log.py
# def debug(s, inst=None):
#     s = "[debug] " + s
#     if inst is not None:
#         s += " (%r)" % inst
#     logger.debug(s)
# 
# Path: pyftpdlib/log.py
# def is_logging_configured():
#     if logging.getLogger('pyftpdlib').handlers:
#         return True
#     if logging.root.handlers:
#         return True
#     return False
# 
# Path: pyftpdlib/log.py
# def _stderr_supports_color():
#     def __init__(self, *args, **kwargs):
#     def format(self, record):
# def debug(s, inst=None):
# def is_logging_configured():
# def config_logging(level=LEVEL, prefix=PREFIX, other_loggers=None):
# LEVEL = logging.INFO
# PREFIX = '[%(levelname)1.1s %(asctime)s]'
# PREFIX_MPROC = '[%(levelname)1.1s %(asctime)s %(process)s]'
# COLOURED = _stderr_supports_color()
# TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
#     PREFIX = PREFIX
# class LogFormatter(logging.Formatter):


import asynchat
import asyncore
import errno
import heapq
import os
import select
import socket
import sys
import time
import traceback
    import threading
    import dummy_threading as threading
from ._compat import callable
from .log import config_logging
from .log import debug
from .log import is_logging_configured
from .log import logger
    """Run the scheduled functions due to expire soonest (if any)."""

    def __init__(self):
        # the heap used for the scheduled tasks
        self._tasks = []
        self._cancellations = 0

    def poll(self):
        """Run the scheduled functions due to expire soonest and
        return the timeout of the next one (if any, else None).
        """
        now = timer()
        calls = []
        while self._tasks:
            if now < self._tasks[0].timeout:
                break
            call = heapq.heappop(self._tasks)
            if call.cancelled:
                self._cancellations -= 1
            else:
                calls.append(call)

        for call in calls:
            if call._repush:
                heapq.heappush(self._tasks, call)
                call._repush = False
                continue
            try:
                call.call()
            except Exception:

# Path: pyftpdlib/_compat.py
# def callable(obj):
#     for klass in type(obj).__mro__:
#         if "__call__" in klass.__dict__:
#             return True
#     return False
# 
# Path: pyftpdlib/log.py
# def config_logging(level=LEVEL, prefix=PREFIX, other_loggers=None):
#     # Little speed up
#     if "(process)" not in prefix:
#         logging.logProcesses = False
#     if "%(processName)s" not in prefix:
#         logging.logMultiprocessing = False
#     if "%(thread)d" not in prefix and "%(threadName)s" not in prefix:
#         logging.logThreads = False
#     handler = logging.StreamHandler()
#     formatter = LogFormatter()
#     formatter.PREFIX = prefix
#     handler.setFormatter(formatter)
#     loggers = [logging.getLogger('pyftpdlib')]
#     if other_loggers is not None:
#         loggers.extend(other_loggers)
#     for logger in loggers:
#         logger.setLevel(level)
#         logger.addHandler(handler)
# 
# Path: pyftpdlib/log.py
# def debug(s, inst=None):
#     s = "[debug] " + s
#     if inst is not None:
#         s += " (%r)" % inst
#     logger.debug(s)
# 
# Path: pyftpdlib/log.py
# def is_logging_configured():
#     if logging.getLogger('pyftpdlib').handlers:
#         return True
#     if logging.root.handlers:
#         return True
#     return False
# 
# Path: pyftpdlib/log.py
# def _stderr_supports_color():
#     def __init__(self, *args, **kwargs):
#     def format(self, record):
# def debug(s, inst=None):
# def is_logging_configured():
# def config_logging(level=LEVEL, prefix=PREFIX, other_loggers=None):
# LEVEL = logging.INFO
# PREFIX = '[%(levelname)1.1s %(asctime)s]'
# PREFIX_MPROC = '[%(levelname)1.1s %(asctime)s %(process)s]'
# COLOURED = _stderr_supports_color()
# TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
#     PREFIX = PREFIX
# class LogFormatter(logging.Formatter):


# Path: pyftpdlib/ioloop.py
import asynchat
import asyncore
import errno
import heapq
import os
import select
import socket
import sys
import time
import traceback
    import threading
    import dummy_threading as threading
from ._compat import callable
from .log import config_logging
from .log import debug
from .log import is_logging_configured
from .log import logger

    """Run the scheduled functions due to expire soonest (if any)."""

    def __init__(self):
        # the heap used for the scheduled tasks
        self._tasks = []
        self._cancellations = 0

    def poll(self):
        """Run the scheduled functions due to expire soonest and
        return the timeout of the next one (if any, else None).
        """
        now = timer()
        calls = []
        while self._tasks:
            if now < self._tasks[0].timeout:
                break
            call = heapq.heappop(self._tasks)
            if call.cancelled:
                self._cancellations -= 1
            else:
                calls.append(call)

        for call in calls:
            if call._repush:
                heapq.heappush(self._tasks, call)
                call._repush = False
                continue
            try:
                call.call()
            except Exception:

                logger.error(traceback.format_exc())