1
1
# noinspection PyPackageRequirements
2
2
from sanic .exceptions import NotFound
3
3
from sqlalchemy .engine .url import URL
4
- try :
5
- # noinspection PyPackageRequirements
6
- from aiocontextvars import enable_inherit , disable_inherit
7
- except ImportError :
8
- enable_inherit = disable_inherit = lambda loop : None
9
4
10
5
from ..api import Gino as _Gino , GinoExecutor as _Executor
11
6
from ..engine import GinoConnection as _Connection , GinoEngine as _Engine
@@ -86,8 +81,6 @@ def __init__(self, app=None, *args, **kwargs):
86
81
self .init_app (app )
87
82
88
83
def init_app (self , app ):
89
- inherit_enabled = [False ]
90
-
91
84
if app .config .setdefault ('DB_USE_CONNECTION_FOR_REQUEST' , True ):
92
85
@app .middleware ('request' )
93
86
async def on_request (request ):
@@ -101,10 +94,6 @@ async def on_response(request, _):
101
94
102
95
@app .listener ('before_server_start' )
103
96
async def before_server_start (_ , loop ):
104
- if app .config .setdefault ('DB_USE_CONNECTION_FOR_REQUEST' , True ):
105
- enable_inherit (loop )
106
- inherit_enabled [0 ] = True
107
-
108
97
if app .config .get ('DB_DSN' ):
109
98
dsn = app .config .DB_DSN
110
99
else :
@@ -128,9 +117,6 @@ async def before_server_start(_, loop):
128
117
@app .listener ('after_server_stop' )
129
118
async def after_server_stop (_ , loop ):
130
119
await self .pop_bind ().close ()
131
- if inherit_enabled [0 ]:
132
- disable_inherit (loop )
133
- inherit_enabled [0 ] = False
134
120
135
121
async def first_or_404 (self , * args , ** kwargs ):
136
122
rv = await self .first (* args , ** kwargs )
0 commit comments