# Path: web/webrun.py
# def web_handler():


import time
import ConfigParser
import importlib
import multiprocessing
from q_twitchbeagle import q_twitchbeagle
from web import webrun
'''

def twitchbeaglerun():
    #from web import webrun
    Config = ConfigParser.ConfigParser()
    Config.read('config.ini')
    enabledModules = Config.get('MODULES', 'enabled').split(',')
    moduleThreads = {}

    for module in enabledModules:
        moduleThreads[module] = {}
        moduleThreads[module]['import'] = importlib.import_module(
                '%s.%srun' % (module, module)
        ) 
        moduleThreads[module]['function'] = getattr(
                moduleThreads[module]['import'],
                '%s_handler' % module
        )
        moduleThreads[module]['queue'] = multiprocessing.queues.Queue()
        #TODO: Test performance using multiprocessing vs. threading
        #moduleThreads[module]['thread'] = Thread( 
        moduleThreads[module]['thread'] = multiprocessing.Process( 
                target = moduleThreads[module]['function'],
                args = (q_twitchbeagle, moduleThreads[module]['queue'])
        )
        #moduleThreads[module]['thread'].setDaemon(True)
        moduleThreads[module]['thread'].start()

    moduleThreads['web'] = {}
    moduleThreads['web']['thread'] = multiprocessing.Process(

# Path: web/webrun.py
# def web_handler():


# Path: run.py
import time
import ConfigParser
import importlib
import multiprocessing
from q_twitchbeagle import q_twitchbeagle
from web import webrun

'''

def twitchbeaglerun():
    #from web import webrun
    Config = ConfigParser.ConfigParser()
    Config.read('config.ini')
    enabledModules = Config.get('MODULES', 'enabled').split(',')
    moduleThreads = {}

    for module in enabledModules:
        moduleThreads[module] = {}
        moduleThreads[module]['import'] = importlib.import_module(
                '%s.%srun' % (module, module)
        ) 
        moduleThreads[module]['function'] = getattr(
                moduleThreads[module]['import'],
                '%s_handler' % module
        )
        moduleThreads[module]['queue'] = multiprocessing.queues.Queue()
        #TODO: Test performance using multiprocessing vs. threading
        #moduleThreads[module]['thread'] = Thread( 
        moduleThreads[module]['thread'] = multiprocessing.Process( 
                target = moduleThreads[module]['function'],
                args = (q_twitchbeagle, moduleThreads[module]['queue'])
        )
        #moduleThreads[module]['thread'].setDaemon(True)
        moduleThreads[module]['thread'].start()

    moduleThreads['web'] = {}
    moduleThreads['web']['thread'] = multiprocessing.Process(

            target = webrun.web_handler