@@ -40,15 +40,14 @@ def __init__(self, loop, cache=None, timeout=300, operation_timeout=None,
40
40
41
41
def __del__ (self ):
42
42
if self ._close_session :
43
- self .session .close ()
43
+ self .session .connector . close ()
44
44
45
45
def _load_remote_data (self , url ):
46
46
result = None
47
47
48
48
async def _load_remote_data_async ():
49
49
nonlocal result
50
- with aiohttp .Timeout (self .load_timeout ):
51
- response = await self .session .get (url )
50
+ async with self .session .get (url , timeout = self .load_timeout ) as response :
52
51
result = await response .read ()
53
52
try :
54
53
response .raise_for_status ()
@@ -65,9 +64,8 @@ async def _load_remote_data_async():
65
64
66
65
async def post (self , address , message , headers ):
67
66
self .logger .debug ("HTTP Post to %s:\n %s" , address , message )
68
- with aiohttp .Timeout (self .operation_timeout ):
69
- response = await self .session .post (
70
- address , data = message , headers = headers )
67
+ async with self .session .post (address , data = message , headers = headers ,
68
+ timeout = self .operation_timeout ) as response :
71
69
self .logger .debug (
72
70
"HTTP Response from %s (status: %d):\n %s" ,
73
71
address , response .status , await response .read ())
@@ -79,9 +77,8 @@ async def post_xml(self, address, envelope, headers):
79
77
return await self .new_response (response )
80
78
81
79
async def get (self , address , params , headers ):
82
- with aiohttp .Timeout (self .operation_timeout ):
83
- response = await self .session .get (
84
- address , params = params , headers = headers )
80
+ async with self .session .get (address , params = params , headers = headers ,
81
+ timeout = self .operation_timeout ) as response :
85
82
86
83
return await self .new_response (response )
87
84
0 commit comments