gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

40 行
1.4KB

  1. """
  2. Running mode flags (gevent, prefork)
  3. This should be imported as early as possible.
  4. It will initialize the `odoo.evented` variable.
  5. """
  6. import odoo
  7. import sys
  8. odoo.evented = False
  9. def patch_evented():
  10. if odoo.evented or not (len(sys.argv) > 1 and sys.argv[1] == 'gevent'):
  11. return
  12. sys.argv.remove('gevent')
  13. import gevent.monkey # noqa: PLC0415
  14. import psycopg2 # noqa: PLC0415
  15. from gevent.socket import wait_read, wait_write # noqa: PLC0415
  16. gevent.monkey.patch_all()
  17. def gevent_wait_callback(conn, timeout=None):
  18. """A wait callback useful to allow gevent to work with Psycopg."""
  19. # Copyright (C) 2010-2012 Daniele Varrazzo <daniele.varrazzo@gmail.com>
  20. # This function is borrowed from psycogreen module which is licensed
  21. # under the BSD license (see in odoo/debian/copyright)
  22. while 1:
  23. state = conn.poll()
  24. if state == psycopg2.extensions.POLL_OK:
  25. break
  26. elif state == psycopg2.extensions.POLL_READ:
  27. wait_read(conn.fileno(), timeout=timeout)
  28. elif state == psycopg2.extensions.POLL_WRITE:
  29. wait_write(conn.fileno(), timeout=timeout)
  30. else:
  31. raise psycopg2.OperationalError(
  32. "Bad result from poll: %r" % state)
  33. psycopg2.extensions.set_wait_callback(gevent_wait_callback)
  34. odoo.evented = True
上海开阖软件有限公司 沪ICP备12045867号-1