Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 4, 2024
1 parent d0e4777 commit a65e93c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/aiida/engine/transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import contextvars
import logging
import traceback
from datetime import datetime
from typing import TYPE_CHECKING, Awaitable, Dict, Hashable, Iterator, Optional

from aiida.common import timezone
Expand All @@ -32,13 +31,15 @@ def __init__(self):
self.future: asyncio.Future = asyncio.Future()
self.count = 0


class TransportCloseRequest:
"""Information kept about close request for a transport object"""

def __init__(self):
self.future: asyncio.Future = asyncio.Future()
self.count = 0


class TransportQueue:
"""A queue to get transport objects from authinfo. This class allows clients
to register their interest in a transport object which will be provided at
Expand Down Expand Up @@ -121,7 +122,9 @@ def do_open():

else:
# Otherwise, wait only the difference required until the `safe_open_interval` is reached
open_callback_handle = self._loop.call_later(safe_open_interval-close_timedelta, do_open, context=contextvars.Context())
open_callback_handle = self._loop.call_later(
safe_open_interval - close_timedelta, do_open, context=contextvars.Context()
)

try:
transport_request.count += 1
Expand All @@ -140,7 +143,6 @@ def do_open():
# Check if there are no longer any users that want the transport
if transport_request.count == 0:
if transport_request.future.done():

_LOGGER.debug('Transport request closing transport for %s', authinfo)
transport_request.future.result().close()

Expand Down

0 comments on commit a65e93c

Please sign in to comment.