<commit_before>"""The application's Globals object"""

from theory.model.mpdhelper import *
from theory.model.mpdpool import QueuePool
from theory.model.tconfig import TConfig
from pylons import config

class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application
    """
    def get_mpd_conn(self):
        m = mpdhelper(self)
        return m

    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """

        self.p = QueuePool(self.get_mpd_conn, max_overflow=0, pool_size=2, use_threadlocal=True)
        self.tc = TConfig()
        self.get_genres()
        pass

    def get_genres(self):
        """ load all tracks and create a list of every unique genre in the database"""
        self.genres = []

        # this won't work before configuration
        try:
            m = self.p.connect()
            all_tracks = m.listallinfo()
            
            for t in all_tracks:
                if not t.has_key('genre'):
                    continue

                if type(t['genre']) == list:
                    track_genres = t['genre']
                else:
                    track_genres = [t['genre']]

                for genre in track_genres:
                    if genre not in self.genres:
                        self.genres.append(genre)
        except:
            pass
<commit_msg>tweaked timeout settings and overflow size<commit_after>"""The application's Globals object"""

from theory.model.mpdhelper import *
from theory.model.mpdpool import QueuePool
from theory.model.tconfig import TConfig
from pylons import config

class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application
    """
    def get_mpd_conn(self):
        m = mpdhelper(self)
        return m

    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """

        self.p = QueuePool(self.get_mpd_conn, max_overflow=1, pool_size=2, use_threadlocal=True,timeout=5)
        self.tc = TConfig()
        self.get_genres()
        pass

    def get_genres(self):
        """ load all tracks and create a list of every unique genre in the database"""
        self.genres = []

        # this won't work before configuration
        try:
            m = self.p.connect()
            all_tracks = m.listallinfo()
            
            for t in all_tracks:
                if not t.has_key('genre'):
                    continue

                if type(t['genre']) == list:
                    track_genres = t['genre']
                else:
                    track_genres = [t['genre']]

                for genre in track_genres:
                    if genre not in self.genres:
                        self.genres.append(genre)
        except:
            pass

{'fraction_non_alphanumeric': 0.08155212101282473, 'fraction_numerical': 0.001644195988161789, 'mean_word_length': 1.8062730627306274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2819435', 'n_tokens_mistral': 850, 'n_tokens_neox': 811, 'n_words': 255}