diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ba6c4a..ee09fd2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,7 +11,7 @@ on: jobs: lint: - runs-on: [self-hosted, Linux, Build] + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Python 3.13 @@ -28,7 +28,7 @@ jobs: run: mypy bfxapi/ test: - runs-on: [self-hosted, Linux, Build] + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - name: Set up Python 3.13 diff --git a/.github/workflows/copilot-reviewer.yml b/.github/workflows/copilot-reviewer.yml index 745d07b..04b8ffd 100644 --- a/.github/workflows/copilot-reviewer.yml +++ b/.github/workflows/copilot-reviewer.yml @@ -8,5 +8,5 @@ permissions: jobs: request: - uses: CloudIngenium/.github/.github/workflows/request-copilot-review.yml@main + uses: CloudIngenium/.github/.github/workflows/request-copilot-review.yml@24fac1de6a37800bae89a7b4f858742c7a455043 secrets: inherit diff --git a/.github/workflows/secret-scan.yml b/.github/workflows/secret-scan.yml index 6570baa..0710a6e 100644 --- a/.github/workflows/secret-scan.yml +++ b/.github/workflows/secret-scan.yml @@ -29,7 +29,7 @@ concurrency: jobs: gitleaks: name: Secret Scan - runs-on: [self-hosted, Linux, Build] + runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: contents: read diff --git a/.github/workflows/socket-security.yml b/.github/workflows/socket-security.yml index e396bd4..3469019 100644 --- a/.github/workflows/socket-security.yml +++ b/.github/workflows/socket-security.yml @@ -11,5 +11,5 @@ concurrency: cancel-in-progress: true jobs: socket: - uses: CloudIngenium/.github/.github/workflows/socket-security.yml@main + uses: CloudIngenium/.github/.github/workflows/socket-security.yml@24fac1de6a37800bae89a7b4f858742c7a455043 secrets: inherit diff --git a/bfxapi/rest/_interface/middleware.py b/bfxapi/rest/_interface/middleware.py index 4d85f35..1d180b1 100644 --- a/bfxapi/rest/_interface/middleware.py +++ b/bfxapi/rest/_interface/middleware.py @@ -8,21 +8,6 @@ from enum import IntEnum from typing import TYPE_CHECKING, Any, NoReturn -_NONCE_LOCK = threading.Lock() -_NONCE_LAST = 0 - - -def _next_nonce() -> str: - """Monotonic microsecond nonce. Guards against duplicates when two calls - hit the same microsecond tick under concurrent use (H8 fix).""" - global _NONCE_LAST - with _NONCE_LOCK: - candidate = time.time_ns() // 1_000 - if candidate <= _NONCE_LAST: - candidate = _NONCE_LAST + 1 - _NONCE_LAST = candidate - return str(candidate) - import requests from bfxapi._utils.json_decoder import JSONDecoder @@ -39,6 +24,21 @@ def _next_nonce() -> str: if TYPE_CHECKING: from requests.sessions import _Params +_NONCE_LOCK = threading.Lock() +_NONCE_LAST = 0 + + +def _next_nonce() -> str: + """Monotonic microsecond nonce. Guards against duplicates when two calls + hit the same microsecond tick under concurrent use (H8 fix).""" + global _NONCE_LAST + with _NONCE_LOCK: + candidate = time.time_ns() // 1_000 + if candidate <= _NONCE_LAST: + candidate = _NONCE_LAST + 1 + _NONCE_LAST = candidate + return str(candidate) + @dataclass class RateLimitInfo: diff --git a/bfxapi/websocket/_handlers/auth_events_handler.py b/bfxapi/websocket/_handlers/auth_events_handler.py index 8bd3bc6..bb384c4 100644 --- a/bfxapi/websocket/_handlers/auth_events_handler.py +++ b/bfxapi/websocket/_handlers/auth_events_handler.py @@ -52,9 +52,7 @@ class AuthEventsHandler: } __SERIALIZERS: dict[str, _Serializer[Any]] = { - abbr: ser - for abbrs, ser in _GROUPED.items() - for abbr in abbrs + abbr: ser for abbrs, ser in _GROUPED.items() for abbr in abbrs } def __init__(self, event_emitter: EventEmitter) -> None: @@ -79,12 +77,9 @@ def handle(self, abbrevation: str, stream: Any) -> None: if serializer is not None: event = AuthEventsHandler.__ABBREVIATIONS[abbrevation] - if all( - isinstance(sub_stream, list) for sub_stream in stream - ): + if all(isinstance(sub_stream, list) for sub_stream in stream): data: Any = [ - serializer.parse(*sub_stream) - for sub_stream in stream + serializer.parse(*sub_stream) for sub_stream in stream ] else: data = serializer.parse(*stream)