# Path: core/config.py
# def full_path(path_to_config):
# def _import(filename):
# def create_if_not_exist(directory):
#     def update(self, new_values):
# def setup_config(path_to_config):
# class Config(object):
# 
# Path: core/exceptions.py
# class SessionException(Exception):
#     pass


import time
import logging
from collections import OrderedDict
from threading import Thread, Lock
from core.config import config
from core.exceptions import SessionException

    def active(self, provider_id=None):
        return self.db.get_active_sessions(provider_id=provider_id)

    def running(self, cached=False):
        if cached:
            return [s for s in self._cache.values() if s.is_running]
        else:
            return [s for s in self.active() if s.is_running]

    def waiting(self):
        return [s for s in self.active() if s.is_waiting]

    def kill_all(self):
        for session in self.active():
            session.failed()

    def get_session(self, session_id, maybe_closed=False):
        """
        :param session_id: integer
        :param maybe_closed: boolean
        :return: Session
        """
        try:
            session = self._cache[session_id]
        except (KeyError, TypeError):
            log.debug('Cache miss (item={})'.format(session_id))
            session = self.db.get_session(session_id)

        if not session:

# Path: core/config.py
# def full_path(path_to_config):
# def _import(filename):
# def create_if_not_exist(directory):
#     def update(self, new_values):
# def setup_config(path_to_config):
# class Config(object):
# 
# Path: core/exceptions.py
# class SessionException(Exception):
#     pass


# Path: core/sessions.py
import time
import logging
from collections import OrderedDict
from threading import Thread, Lock
from core.config import config
from core.exceptions import SessionException


    def active(self, provider_id=None):
        return self.db.get_active_sessions(provider_id=provider_id)

    def running(self, cached=False):
        if cached:
            return [s for s in self._cache.values() if s.is_running]
        else:
            return [s for s in self.active() if s.is_running]

    def waiting(self):
        return [s for s in self.active() if s.is_waiting]

    def kill_all(self):
        for session in self.active():
            session.failed()

    def get_session(self, session_id, maybe_closed=False):
        """
        :param session_id: integer
        :param maybe_closed: boolean
        :return: Session
        """
        try:
            session = self._cache[session_id]
        except (KeyError, TypeError):
            log.debug('Cache miss (item={})'.format(session_id))
            session = self.db.get_session(session_id)

        if not session:

            raise SessionException("There is no active session {} (Unknown session)".format(session_id))