<commit_before>import tornado.ioloop
import tornado.web
from metadataservice.server.engine import (db_connect, RunStartHandler, RunStopHandler,
                                           EventDescriptorHandler, EventHandler,
                                           CappedRunStartHandler, CappedRunStopHandler, 
                                           loop)


db = db_connect('datastore2', '127.0.0.1', 27017)

application = tornado.web.Application([
    (r'/run_start', RunStartHandler), (r'/run_stop', RunStopHandler),
    (r'/event_descriptor',EventDescriptorHandler),
    (r'/event',EventHandler),
    (r'/run_start_capped', CappedRunStartHandler),
    (r'/run_stop_capped', CappedRunStopHandler)], db=db)
application.listen(7770)
loop.start()<commit_msg>ENH: Server startup is now guaranteed to be in the main thread<commit_after>import tornado.ioloop
import tornado.web
from metadataservice.server.engine import (db_connect, RunStartHandler, RunStopHandler,
                                           EventDescriptorHandler, EventHandler,
                                           CappedRunStartHandler, CappedRunStopHandler, 
                                           loop)


db = db_connect('datastore2', '127.0.0.1', 27017)



if __name__ == "__main__":
    application = tornado.web.Application([
        (r'/run_start', RunStartHandler), (r'/run_stop', RunStopHandler),
        (r'/event_descriptor',EventDescriptorHandler),
        (r'/event',EventHandler),
        (r'/run_start_capped', CappedRunStartHandler),
        (r'/run_stop_capped', CappedRunStopHandler)], db=db)
    application.listen(7770)
    loop.start()
{'fraction_non_alphanumeric': 0.10622710622710622, 'fraction_numerical': 0.019536019536019536, 'mean_word_length': 2.5630434782608695, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4605481', 'n_tokens_mistral': 473, 'n_tokens_neox': 429, 'n_words': 81}