def post_fork(server, worker): server.log.info("Worker spawned (pid: %s)", worker.pid) from util.cass import get_session, create_execution_pool with worker_lock: worker.log.debug('Connecting worker to cassandra') get_session() worker.log.debug('Connected worker to cassandra') worker.log.debug('Worker creating execution pool') create_execution_pool() worker.log.debug('Worker created execution pool') preload_database.database.open_connection()
def setUpClass(cls): os.chdir(TEST_DIR) if not os.path.exists(TEST_DIR + '/TEST_DATA_LOADED'): subprocess.call(['cqlsh', '-f', TEST_DIR + '/load.cql']) open(TEST_DIR + '/TEST_DATA_LOADED', 'wb').write('%s\n' % time.ctime()) app.config['CASSANDRA_KEYSPACE'] = StreamUnitTest.TEST_KEYSPACE cluster = Cluster(app.config['CASSANDRA_CONTACT_POINTS'], control_connection_timeout=app.config['CASSANDRA_CONNECT_TIMEOUT']) global_cassandra_state['cluster'] = cluster create_execution_pool()
#!/usr/bin/env python from werkzeug.contrib.profiler import ProfilerMiddleware from util.cass import get_session, create_execution_pool import preload_database.database preload_database.database.initialize_connection(preload_database.database.PreloadDatabaseMode.POPULATED_FILE) preload_database.database.open_connection() get_session() create_execution_pool() from engine.routes import app app.config['PROFILE'] = True app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30]) app.run(debug=True)