Remove weakref usage

If a connection escapes the scope of the
backend object, then python will actually
garbage collect the backend object even
though the connection object has a property
that allows you to fetch the backend. If the
property is used after the gc occurs a weakref
failure occurs.

Python is smart enough to correctly deallocate
these types of object links by itself so lets
just let it do that.

Fixes: bug 1228968

Change-Id: I49d36b74f896bd1be6c7a1a373b07bdaded3ef4b
This commit is contained in:
Joshua Harlow
2013-09-20 23:18:03 -07:00
parent c108f6a1f5
commit 134d0951b0
2 changed files with 2 additions and 4 deletions

View File

@@ -22,7 +22,6 @@
import copy
import logging
import threading
import weakref
from taskflow import decorators
from taskflow import exceptions as exc
@@ -63,7 +62,7 @@ class Connection(base.Connection):
def __init__(self, backend):
self._read_lock = _READ_LOCK
self._save_locks = _READ_SAVE_ORDER
self._backend = weakref.proxy(backend)
self._backend = backend
def upgrade(self):
pass

View File

@@ -25,7 +25,6 @@ import contextlib
import copy
import logging
import time
import weakref
import sqlalchemy as sa
from sqlalchemy import exceptions as sa_exc
@@ -260,7 +259,7 @@ class SQLAlchemyBackend(base.Backend):
class Connection(base.Connection):
def __init__(self, backend, session_maker):
self._backend = weakref.proxy(backend)
self._backend = backend
self._session_maker = session_maker
self._engine = backend.engine