Ticket #125 (closed Defect: Fixed)
Use of deprecated function of python-mysqldb
| Reported by: | keiser3354 | Owned by: | adigeo |
|---|---|---|---|
| Priority: | Major | Milestone: | OpenXCAP 1.2.0 |
| Component: | Storage backend | Version: | trunk |
| Severity: | Non-critical | Keywords: | mysqldb, depracated |
| Cc: |
Description
With MySQL-python-1.2.3c1.tar.gz, following errors appear:
=> openxcap --no-fork Starting OpenXCAP 1.1.1 xcap.server.HTTPFactory starting on 443 TLS started error: Traceback (most recent call last): error: File "/usr/local/lib/python2.5/threading.py", line 462, in __bootstrap error: self.__bootstrap_inner() error: File "/usr/local/lib/python2.5/threading.py", line 486, in __bootstrap_inner error: self.run() error: File "/usr/local/lib/python2.5/threading.py", line 446, in run error: self.__target(*self.__args, **self.__kwargs) error: --- <exception caught here> --- error: File "/usr/local/lib/python2.5/site-packages/twisted/python/threadpool.py", line 210, in _worker error: result = context.call(ctx, function, *args, **kwargs) error: File "/usr/local/lib/python2.5/site-packages/twisted/python/context.py", line 59, in callWithContext error: return self.currentContext().callWithContext(ctx, func, *args, **kw) error: File "/usr/local/lib/python2.5/site-packages/twisted/python/context.py", line 37, in callWithContext error: return func(*args,**kw) error: File "/usr/local/lib/python2.5/site-packages/twisted/enterprise/adbapi.py", line 426, in _runInteraction error: conn = self.connectionFactory(self) error: File "/usr/local/lib/python2.5/site-packages/twisted/enterprise/adbapi.py", line 38, in __init__ error: self.reconnect() error: File "/usr/local/lib/python2.5/site-packages/twisted/enterprise/adbapi.py", line 75, in reconnect error: self._connection = self._pool.connect() error: File "/usr/local/lib/python2.5/site-packages/twisted/enterprise/adbapi.py", line 395, in connect error: conn = self.dbapi.connect(*self.connargs, **self.connkw) error: File "build/bdist.linux-i686/egg/MySQLdb/__init__.py", line 81, in Connect error: File "build/bdist.linux-i686/egg/MySQLdb/connections.py", line 188, in __init__ error: exceptions.TypeError: 'reconnect' is an invalid keyword argument for this function
No error with MySQL-python 1.2.1_p2.
Change History
comment:1 Changed 2 years ago by keiser3354
- Priority changed from Minor to Critical
- Severity changed from Non-critical to Critical
comment:2 Changed 2 years ago by keiser3354
- Priority changed from Critical to Major
- Severity changed from Critical to Non-critical
Workaround found editing dbutil.py, in connectionForURI(uri): lines 98 and 99, if condition on MySQLdb version generates an error with MySQLdb >= 1.2.2. My code is now:
def connectionForURI(uri):
"""Return a Twisted adbapi connection pool for a given database URI."""
schema, user, password, host, port, path, args = parseURI(uri)
try:
module = db_modules[schema]
except Exception:
raise ValueError("Database scheme '%s' is not supported." % schema)
# reconnecting is safe since we don't use transactions.
# the following code prefers MySQLdb native reconnect if it's available,
# falling back to twisted's cp_reconnect.
# mysql's reconnect is preferred because it's better tested than twisted's
kwargs = {}
if module == 'MySQLdb':
MySQLdb = reflect.namedModule(module)
#if MySQLdb.version_info[:3] >= (1, 2, 2):
# kwargs.setdefault('reconnect', 1)
kwargs.setdefault('host', host or 'localhost')
kwargs.setdefault('user', user or '')
kwargs.setdefault('passwd', password or '')
path = path.lstrip('/')
kwargs.setdefault('db', path)
args = ()
elif module == 'sqlite3':
if path == ':memory:':
# otherwise a database per connection is created
kwargs['cp_min'] = kwargs['cp_max'] = 1
args = (path, )
if 'reconnect' not in kwargs:
# note that some versions of MySQLdb don't provide reconnect parameter,
# but set it to 1.
# hopefully, if underlying reconnect was enabled, twisted will never see
# a disconnect and its reconnection code won't interfere.
kwargs.setdefault('cp_reconnect', 1)
kwargs.setdefault('cp_noisy', False)
pool = adbapi.ConnectionPool(module, *args, **kwargs)
pool.schema = schema
return pool
Should see what's wrong with these lines (<= intead of >= ???).
Note: See
TracTickets for help on using
tickets.

updated to critical because the same error appears with MySQL-python 1.2.2 which is required to solve ticket #18 !!