# 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 update_log_step(log_step, message=None, control_line=None):
    if message:
        log_step.body = message
    if control_line:
        log_step.control_line = control_line
    log_step.save()


class SimpleResponse:
    def __init__(self, status_code=None, headers=None, content=None):
        self.status_code = status_code
        self.headers = headers
        self.content = content


class SessionWorker(Thread):
    def __init__(self, sessions, context):
        Thread.__init__(self)
        self.running = True
        self.daemon = True
        self.sessions = sessions
        self.context = context

    def run(self):
        log.info("SessionWorker started")
        while self.running:
            with self.context():
                for session in self.sessions.running(cached=True):

# 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 update_log_step(log_step, message=None, control_line=None):
    if message:
        log_step.body = message
    if control_line:
        log_step.control_line = control_line
    log_step.save()


class SimpleResponse:
    def __init__(self, status_code=None, headers=None, content=None):
        self.status_code = status_code
        self.headers = headers
        self.content = content


class SessionWorker(Thread):
    def __init__(self, sessions, context):
        Thread.__init__(self)
        self.running = True
        self.daemon = True
        self.sessions = sessions
        self.context = context

    def run(self):
        log.info("SessionWorker started")
        while self.running:
            with self.context():
                for session in self.sessions.running(cached=True):

                    if not session.is_active and session.inactivity > config.SESSION_TIMEOUT: