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 copy
|
||||||
import logging
|
import logging
|
||||||
import threading
|
import threading
|
||||||
import weakref
|
|
||||||
|
|
||||||
from taskflow import decorators
|
from taskflow import decorators
|
||||||
from taskflow import exceptions as exc
|
from taskflow import exceptions as exc
|
||||||
@@ -63,7 +62,7 @@ class Connection(base.Connection):
|
|||||||
def __init__(self, backend):
|
def __init__(self, backend):
|
||||||
self._read_lock = _READ_LOCK
|
self._read_lock = _READ_LOCK
|
||||||
self._save_locks = _READ_SAVE_ORDER
|
self._save_locks = _READ_SAVE_ORDER
|
||||||
self._backend = weakref.proxy(backend)
|
self._backend = backend
|
||||||
|
|
||||||
def upgrade(self):
|
def upgrade(self):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import contextlib
|
|||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
import weakref
|
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import exceptions as sa_exc
|
from sqlalchemy import exceptions as sa_exc
|
||||||
@@ -260,7 +259,7 @@ class SQLAlchemyBackend(base.Backend):
|
|||||||
|
|
||||||
class Connection(base.Connection):
|
class Connection(base.Connection):
|
||||||
def __init__(self, backend, session_maker):
|
def __init__(self, backend, session_maker):
|
||||||
self._backend = weakref.proxy(backend)
|
self._backend = backend
|
||||||
self._session_maker = session_maker
|
self._session_maker = session_maker
|
||||||
self._engine = backend.engine
|
self._engine = backend.engine
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user