19 lines
460 B
Python
19 lines
460 B
Python
import threading
|
|
import time
|
|
|
|
class MockBridge:
|
|
def __init__(self):
|
|
self._lock = threading.Lock()
|
|
|
|
def busy(self):
|
|
return self._lock.locked()
|
|
|
|
def send_and_read_once(self, payload: bytes):
|
|
if not self._lock.acquire(blocking=False):
|
|
return {"busy": True, "error": "BUSY"}
|
|
try:
|
|
time.sleep(0.1)
|
|
return {"ok": True, "response": "OK"}
|
|
finally:
|
|
self._lock.release()
|