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
@@ -121,7 +120,7 @@ def _multigrid_watcher_finalised(self):
121120 self .multigrid_watcher_active = False
122121 self .dormancy_check ()
123122
124- async def dormancy_check (self ):
123+ def dormancy_check (self ):
125124 if not self .multigrid_watcher_active :
126125 if (
127126 all (r ._finalised for r in self .rsync_processes .values ())
@@ -130,14 +129,22 @@ async def dormancy_check(self):
130129 w .thread .is_alive () for w in self ._environment .watchers .values ()
131130 )
132131 ):
133- async with aiohttp .ClientSession () as clientsession :
134- async with clientsession .delete (
132+
133+ def call_remove_session ():
134+ response = capture_delete (
135135 f"{ self ._environment .url .geturl ()} { url_path_for ('session_control.router' , 'remove_session' , session_id = self .session_id )} " ,
136- json = {"access_token" : self .token , "token_type" : "bearer" },
137- ) as response :
138- success = response .status == 200
139- if not success :
140- log .warning (f"Could not delete database data for { self .session_id } " )
136+ )
137+ success = response .status_code == 200 if response else False
138+ if not success :
139+ log .warning (
140+ f"Could not delete database data for { self .session_id } "
141+ )
142+
143+ dormancy_thread = threading .Thread (
144+ name = f"Session deletion thread { self .session_id } " ,
145+ target = call_remove_session ,
146+ )
147+ dormancy_thread .start ()
141148 self .dormant = True
142149
143150 def abandon (self ):
0 commit comments