99from typing import Dict , List , Optional
1010from urllib .parse import quote , urlparse
1111
12- import aiohttp
1312import requests
1413
1514import murfey .client .websocket
2221from murfey .client .watchdir import DirWatcher
2322from murfey .util import posix_path
2423from murfey .util .api import url_path_for
25- from murfey .util .client import capture_post , get_machine_config_client
24+ from murfey .util .client import capture_delete , capture_post , get_machine_config_client
2625
2726log = logging .getLogger ("murfey.client.mutligrid_control" )
2827
@@ -117,7 +116,7 @@ def _multigrid_watcher_finalised(self):
117116 self .multigrid_watcher_active = False
118117 self .dormancy_check ()
119118
120- async def dormancy_check (self ):
119+ def dormancy_check (self ):
121120 if not self .multigrid_watcher_active :
122121 if (
123122 all (r ._finalised for r in self .rsync_processes .values ())
@@ -126,14 +125,22 @@ async def dormancy_check(self):
126125 w .thread .is_alive () for w in self ._environment .watchers .values ()
127126 )
128127 ):
129- async with aiohttp .ClientSession () as clientsession :
130- async with clientsession .delete (
128+
129+ def call_remove_session ():
130+ with capture_delete (
131131 f"{ self ._environment .url .geturl ()} { url_path_for ('session_control.router' , 'remove_session' , session_id = self .session_id )} " ,
132- json = {"access_token" : self .token , "token_type" : "bearer" },
133132 ) as response :
134- success = response .status == 200
135- if not success :
136- log .warning (f"Could not delete database data for { self .session_id } " )
133+ success = response .status_code == 200 if response else False
134+ if not success :
135+ log .warning (
136+ f"Could not delete database data for { self .session_id } "
137+ )
138+
139+ dormancy_thread = threading .Thread (
140+ name = f"Session deletion thread { self .session_id } " ,
141+ target = call_remove_session ,
142+ )
143+ dormancy_thread .start ()
137144 self .dormant = True
138145
139146 def abandon (self ):
0 commit comments