diff options
| author | Christophe Monniez <moc@odoo.com> | 2017-10-09 15:45:58 +0200 |
|---|---|---|
| committer | Christophe Monniez <moc@odoo.com> | 2017-10-09 18:56:57 +0200 |
| commit | bb14c416634ff925d5f5609e9ad035d26d85c3b4 (patch) | |
| tree | b5d63a9789dc722a471f5fa9745620d22ee8195a /odoo/__init__.py | |
| parent | 9d5c1801bb6718bfc3dfa0db535ee70060f4ec5c (diff) | |
[REF] core: Remove psycogreen dependency
Purpose:
The psycogreen module is unmaintained. Last source update was in
2015 and last pypi package was in 2012. Odoo only use a small
part of the psycogreen module that could be written directly in
the odoo code. This commit reproduce the small function from
psycogreen used in ODoo and remove all depencies from it.
Also the copyright and license are honored and the documentation
is updated accordingly.
pypi pckage: https://pypi.python.org/pypi/psycogreen
bitbucket repos: https://bitbucket.org/dvarrazzo/psycogreen/
Diffstat (limited to 'odoo/__init__.py')
| -rw-r--r-- | odoo/__init__.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/odoo/__init__.py b/odoo/__init__.py index 2814706b57a..c6fa6e3032a 100644 --- a/odoo/__init__.py +++ b/odoo/__init__.py @@ -18,9 +18,27 @@ evented = False if len(sys.argv) > 1 and sys.argv[1] == 'gevent': sys.argv.remove('gevent') import gevent.monkey + import psycopg2 + from gevent.socket import wait_read, wait_write gevent.monkey.patch_all() - import psycogreen.gevent - psycogreen.gevent.patch_psycopg() + + def gevent_wait_callback(conn, timeout=None): + """A wait callback useful to allow gevent to work with Psycopg.""" + # Copyright (C) 2010-2012 Daniele Varrazzo <daniele.varrazzo@gmail.com> + # This function is borrowed from psycogreen module which is licensed + # under the BSD license (see in odoo/debian/copyright) + while 1: + state = conn.poll() + if state == psycopg2.extensions.POLL_OK: + break + elif state == psycopg2.extensions.POLL_READ: + wait_read(conn.fileno(), timeout=timeout) + elif state == psycopg2.extensions.POLL_WRITE: + wait_write(conn.fileno(), timeout=timeout) + else: + raise psycopg2.OperationalError( + "Bad result from poll: %r" % state) + psycopg2.extensions.set_wait_callback(gevent_wait_callback) evented = True # Is the server running in prefork mode (e.g. behind Gunicorn). |
