本文整理汇总了Python中psycogreen.gevent.patch_psycopg函数的典型用法代码示例。如果您正苦于以下问题:Python patch_psycopg函数的具体用法?Python patch_psycopg怎么用?Python patch_psycopg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了patch_psycopg函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: greenify
def greenify():
"""Patch threading and psycopg2 modules for green threads."""
from gevent.monkey import patch_all, saved
if ('threading' in sys.modules) and ('threading' not in saved):
raise Exception('threading module loaded before patching!')
patch_all()
from psycogreen.gevent import patch_psycopg
patch_psycopg()
开发者ID:LegoStormtroopr,项目名称:django-ddp,代码行数:9,代码来源:__init__.py
示例2: postfork
def postfork(server, worker):
# Make sure any lazily initialized SQLAlchemy state, notably the
# `returns_unicode_strings` flag on the engine's `Dialect`, is initialized
# before we start accepting requests. Otherwise, some requests could start
# making queries before the initialization was complete, and those queries
# would observe the incorrect, uninitialized values for certain
# engine/dialect state variables, leading to errors.
angular_momentum.db.get_engine().connect().close()
from psycogreen.gevent import patch_psycopg
patch_psycopg()
开发者ID:holycattle,项目名称:angular-momentum,代码行数:12,代码来源:wsgi.py
示例3: handle
def handle(self, addrport='', *args, **options):
if not addrport:
self.addr = ''
self.port = DEFAULT_PORT
else:
m = match(naiveip_re, addrport)
if m is None:
raise CommandError('"%s" is not a valid port number '
'or address:port pair.' % addrport)
self.addr, _, _, _, self.port = m.groups()
environ['DJANGO_SOCKETIO_PORT'] = str(self.port)
if options.get('use_psyco'):
try:
from psycogreen.gevent import patch_psycopg
except ImportError:
raise CommandError(
'Could not patch psycopg. '
'Is psycogreen installed?')
patch_psycopg()
if options.get('use_reloader'):
start_new_thread(reload_watcher, ())
try:
bind = (self.addr, int(self.port))
print 'SocketIOServer running on %s:%s\n\n' % bind
handler = self.get_handler(*args, **options)
server = SocketIOServer(
bind, handler, resource='socket.io', policy_server=True)
server.serve_forever()
except KeyboardInterrupt:
socks = []
for key, sock in six.iteritems(server.sockets):
socks.append(sock)
for sock in socks:
sock.kill(detach=True)
server.stop()
if RELOAD:
print 'Reloading...\n\n'
restart_with_reloader()
开发者ID:arthur-test-account,项目名称:Romanesco,代码行数:42,代码来源:socketio_runserver.py
示例4: greenify
def greenify():
"""Patch threading and psycopg2 modules for green threads."""
# don't greenify twice.
if _GREEN:
return
_GREEN[True] = True
from gevent.monkey import patch_all, saved
if ('threading' in sys.modules) and ('threading' not in saved):
raise Exception('threading module loaded before patching!')
patch_all()
from psycogreen.gevent import patch_psycopg
patch_psycopg()
try:
# Use psycopg2 by default
import psycopg2
del psycopg2
except ImportError:
# Fallback to psycopg2cffi if required (eg: pypy)
from psycopg2cffi import compat
compat.register()
开发者ID:rajvansia,项目名称:django-ddp,代码行数:23,代码来源:__init__.py
示例5: patch_psycopg
import sqlalchemy as sql
from sqlalchemy import or_
import bottle_sqlalchemy as sqlalchemy
from sqlalchemy import create_engine, Column, Sequence
from sqlalchemy.ext.declarative import declarative_base
import psycopg2, random, urllib, os
from bin.utils import isInt, gen_string
from dataobjects import Debug
from datetime import datetime
from gevent import monkey
monkey.patch_all()
from psycogreen.gevent import patch_psycopg
patch_psycopg()
Base = declarative_base()
class Postgres():
def __init__(self, cfg, app):
self._cfg = cfg
self._db_host = self._cfg.get('Postgres', 'host')
self._db_port = self._cfg.get('Postgres', 'port')
self._db_database = self._cfg.get('Postgres', 'db')
self._db_user = self._cfg.get('Postgres', 'user')
self._db_pass = self._cfg.get('Postgres', 'pass')
self.engine = create_engine('postgresql+psycopg2://%s:%[email protected]%s:%s/%s' % (
self._db_user,
self._db_pass,
self._db_host,
开发者ID:trbs,项目名称:sandexer,代码行数:31,代码来源:orm.py
示例6: pre_fork
def pre_fork(server, worker):
patch_psycopg()
worker.log.info('Patched psycopg with gevent support')
开发者ID:bkuberek,项目名称:feedduty,代码行数:3,代码来源:gunicorn.conf.py
示例7: post_fork
def post_fork(server, worker):
from psycogreen.gevent import patch_psycopg
patch_psycopg()
worker.log.info("Made psycopg Green")
开发者ID:benrito,项目名称:us_ignite,代码行数:4,代码来源:gunicorn_autoreload.py
示例8: post_fork
def post_fork(server, worker):
from psycogreen.gevent import patch_psycopg
patch_psycopg()
开发者ID:IdahoInstitute,项目名称:planbox,代码行数:3,代码来源:gunicorn.conf.py
示例9: patch_psycopg
#!/usr/bin/env python
import os
import sys
from gevent import monkey#; monkey.patch_all()
monkey.patch_os()
monkey.patch_time()
monkey.patch_thread( _threading_local=False)
monkey.patch_sys()
monkey.patch_socket()
monkey.patch_select()
monkey.patch_ssl()
monkey.patch_subprocess()
from psycogreen.gevent import patch_psycopg; patch_psycopg();
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "geventpooltest.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
开发者ID:askholme,项目名称:geventpooltest,代码行数:21,代码来源:manage.py
示例10: post_fork
def post_fork(server, worker):
patch_psycopg()
开发者ID:CityOfPhiladelphia,项目名称:ais,代码行数:2,代码来源:gunicorn.conf.py
示例11: post_fork
def post_fork(server, worker):
patch_psycopg()
worker.log.info("Made Psycopg2 Green")
server.log.info("Worker spawned (pid: %s)", worker.pid)
开发者ID:zhongzhenyang,项目名称:sz_sports_test,代码行数:4,代码来源:gunicorn_app_config.py
示例12: post_fork
def post_fork(server, worker):
os.environ["GEVENT_RESOLVER"] = "ares"
from psycogreen.gevent import patch_psycopg
patch_psycopg()
开发者ID:quyetnd-parlayz,项目名称:gevent-socketio,代码行数:4,代码来源:gunicorn.conf.py
示例13: patch
def patch():
# Patch all the things that gevent knows about.
patch_all()
# Patch psycopg2 to also be gevent friendly.
patch_psycopg()
开发者ID:btubbs,项目名称:todopy-pg,代码行数:6,代码来源:green.py
示例14: post_fork
def post_fork(server, worker):
"""
https://github.com/jneight/django-db-geventpool
"""
patch_psycopg()
worker.log.info("Made Psycopg2 Green")
开发者ID:stefanw,项目名称:seriesly,代码行数:6,代码来源:gunicorn_config.py
注:本文中的psycogreen.gevent.patch_psycopg函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论