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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user