Skip to content

Commit 8c62a42

Browse files
committed
Pass arguments through wrapper
1 parent e2fdd75 commit 8c62a42

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/murfey/server/__init__.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,33 @@ def record_failure(
100100
f: Callable, record_queue: str = "", is_callback: bool = True
101101
) -> Callable:
102102
@wraps(f)
103-
def wrapper(*args, **kwargs):
103+
def wrapper(
104+
*args,
105+
record_queue: str = record_queue,
106+
is_callback: bool = is_callback,
107+
**kwargs,
108+
):
109+
try:
110+
message = args[0]
111+
session_id = message["session_id"]
112+
instrument_name = (
113+
murfey_db.exec(select(db.Session).where(db.Session.id == session_id))
114+
.one()
115+
.instrument_name
116+
)
117+
except Exception:
118+
logger.warning(
119+
"Could not record message failure as the instrument name could not be determined"
120+
)
104121
try:
105122
return f(*args, **kwargs)
106123
except Exception:
107124
logger.warning(f"Call to {f} failed", exc_info=True)
108125
if _transport_object and is_callback:
126+
machine_config = get_machine_config().get(instrument_name)
127+
if not machine_config:
128+
return None
109129
if not record_queue:
110-
machine_config = get_machine_config()
111130
record_queue = (
112131
machine_config.failure_queue
113132
or f"dlq.{_transport_object.feedback_queue}"

0 commit comments

Comments
 (0)