Verified Commit 0a05afd1 authored by Jakob Moser's avatar Jakob Moser
Browse files

Make quitting a bit easier

parent e7ef163e
Loading
Loading
Loading
Loading
+8 −1
Changes for poolpay/card/MockCardReader.py: 8 added lines, 1 removed line.
Original line number Diff line number Diff line
from __future__ import annotations

import sys
from collections.abc import Callable
from dataclasses import dataclass, field

@@ -18,7 +19,13 @@ class MockCardReader(CardReader):

    def on_card_placed(self, handle_card: Callable[[CardReader], None]) -> None:
        while True:
            line = input("Card ID (int) or 'r' to remove card> ").strip()
            print("Card ID (int) or 'r' to remove card> ", end="", flush=True)

            # Using sys.stdin.readline instead of input seems to avoid 'Fatal Python error: _enter_buffered_busy:
            # could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown,
            # possibly due to daemon threads' on terminate. I don't know why (does input hold a lock on stdin,
            # but readline doesn't?), but given that this is only for the mock mode, I'll accept this for now.
            line = sys.stdin.readline().strip()

            if line.lower() == "r":
                if self._card_id is not None: