예제 #1
0
파일: bootstrap.py 프로젝트: Cowoop/cowspa3
def setup_process_model(use_gevent=True):
    if use_gevent:
        import gevent
        import gevent.monkey
        import gevent.local as localprov
        gevent.monkey.patch_all()
        import psyco_gevent
        psyco_gevent.make_psycopg_green()
    else:
        import threading
        localprov = threading
    return localprov
    def initialize(self):
        #        sqlalchemy.dialects.registry.register("postgresql", "sqlalchemy_gevent", "PostgreSQLDialect")
        from sqlalchemy.pool import NullPool
        engine = create_engine(
            'postgresql+psycopg2://sugino:bigbird@localhost/sugino',
            echo=True,
            poolclass=NullPool)

        make_psycopg_green()

        #self.conn = engine.connect()
        #Session = sessionmaker(bind=engine)
        #Session.configure(bind=engine)
        #session = Session()
        self.db = engine
    def initialize(self):
#        sqlalchemy.dialects.registry.register("postgresql", "sqlalchemy_gevent", "PostgreSQLDialect")
        from sqlalchemy.pool import NullPool
        engine = create_engine('postgresql+psycopg2://sugino:bigbird@localhost/sugino', 
                                echo=True, 
                                poolclass=NullPool
                                )

        make_psycopg_green()

        #self.conn = engine.connect()
        #Session = sessionmaker(bind=engine)
        #Session.configure(bind=engine)
        #session = Session()
        self.db = engine
예제 #4
0
#!/usr/bin/env python

PORT = 9000

import os

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

from socketio import SocketIOServer

import psyco_gevent; psyco_gevent.make_psycopg_green()
from gevent.monkey import patch_thread; patch_thread()

if __name__ == '__main__':
    print 'Listening on port %s and on port 843 (flash policy server)' % PORT
    SocketIOServer(('', PORT), application, resource="socket.io").serve_forever()
예제 #5
0
파일: app.py 프로젝트: shinkai76/goBox
sys.setdefaultencoding('utf-8')

if 'threading' in sys.modules:
    raise Exception('threading module loaded before patching!')

import gevent

if '__pypy__' in sys.builtin_module_names:
    from psycopg2cffi import compat
    compat.register()
from gevent import monkey

monkey.patch_all()

from psyco_gevent import make_psycopg_green
make_psycopg_green()

from bottle import Bottle, request, run, static_file, response, abort, template

import bottle
import jwt

app = Bottle()

import settings
from sqlalchemy.orm import sessionmaker
import requests
from models import *
from common import *
from datetime import datetime, timedelta
def def_post_fork(server, worker):
    from psyco_gevent import make_psycopg_green
    make_psycopg_green()
    worker.log.info("Made Psycopg Green")