zodb / relstorage

A backend for ZODB that stores pickles in a relational database.
Other
55 stars 46 forks source link

ModuleNotFoundError: No module named 'gevent' with pyscopg2 #375

Closed brahici closed 4 years ago

brahici commented 4 years ago

Since version 3.0b2, I am experiencing a warning with following code

import ZODB.config

conf = """
%import relstorage
<zodb main>
    <relstorage>
        keep-history false
        <postgresql>
            dsn host=localhost dbname=rspg
        </postgresql>
    </relstorage>
</zodb>
"""
db = ZODB.config.databaseFromString(conf)

Despite the warning, the connection is open and can be used.

The warning is:

Unable to import driver
Traceback (most recent call last):
  File "[...]/site-packages/relstorage/adapters/drivers.py", line 135, in __init__
    self.driver_module = mod = self.get_driver_module()
  File "[...]/site-packages/relstorage/adapters/postgresql/drivers/psycopg2.py", line 173, in get_driver_module
    __import__('gevent')
ModuleNotFoundError: No module named 'gevent'
Unable to import driver
Traceback (most recent call last):
  File "[...]/site-packages/relstorage/adapters/drivers.py", line 135, in __init__
    self.driver_module = mod = self.get_driver_module()
  File "[...]/site-packages/relstorage/adapters/postgresql/drivers/psycopg2.py", line 173, in get_driver_module
    __import__('gevent')
ModuleNotFoundError: No module named 'gevent'

I have tested this against several combinations of python3 versions and relstorage versions, and psycopg2 2.8.4 (each test in a separate virtualenv, detroyed and created before running test script; and each test repeated 5 times):

I am quite puzzled with randomness of warnings; but the warning occurred frequently enough to report an issue.

jamadden commented 4 years ago

There was an issue understanding why a particular driver couldn't be used, so logging was added. But it's at the exception level, which is not really appropriate most of the time. I'll make a tweak. Thanks!