Skip to content

Commit 7b192a3

Browse files
authored
Client close if loop is still running (#760)
1 parent c2d924d commit 7b192a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

s3fs/core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,12 @@ async def set_session(self, refresh=False, kwargs={}):
541541
@staticmethod
542542
def close_session(loop, s3):
543543
if loop is not None and loop.is_running():
544+
try:
545+
loop = asyncio.get_event_loop()
546+
loop.create_task(s3.__aexit__(None, None, None))
547+
return
548+
except RuntimeError:
549+
pass
544550
try:
545551
sync(loop, s3.__aexit__, None, None, None, timeout=0.1)
546552
return

0 commit comments

Comments
 (0)