55from django .core .cache import cache
66from requests .auth import HTTPBasicAuth
77
8- from .utils import random_string , get_session , CacheLock
8+ from .tasks import send_app_log
9+ from .utils import random_string , get_httpclient , CacheLock
910
1011logger = logging .getLogger (__name__ )
1112
@@ -21,6 +22,7 @@ def __init__(self, app_id, volume, scheduler):
2122
2223 def log (self , message , level = logging .INFO ):
2324 logger .log (level , "[{}]: {}" .format (self .app_id , message ))
25+ send_app_log .delay (self .app_id , message , level )
2426
2527 @property
2628 def server (self ):
@@ -90,7 +92,8 @@ def request(self, method, server, path="/", **kwargs):
9092 cache .touch (self .cache_key , timeout = settings .DRYCC_FILER_DURATION )
9193 url = f"http://{ server ["address" ]} :{ self .bind .split (":" )[1 ]} /{ path } "
9294 kwargs ["auth" ] = HTTPBasicAuth (server ["username" ], server ["password" ])
93- return get_session ().request (method , url , ** kwargs )
95+ with get_httpclient () as session :
96+ session .request (method , url , ** kwargs )
9497
9598 def get (self , path , ** kwargs ):
9699 return self .request ("GET" , self .server , path , ** kwargs )
0 commit comments