From 9867ec4787abb16b4c1a2dbd79fe2f9c0eea2fa2 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Mon, 1 Jun 2026 15:16:41 +0400 Subject: [PATCH] Add try and finally to make sure teardown is called --- libplum/plum.nim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libplum/plum.nim b/libplum/plum.nim index cdcadeb..c70fd33 100644 --- a/libplum/plum.nim +++ b/libplum/plum.nim @@ -79,9 +79,11 @@ type template foreignThreadGc(body: untyped) = when declared(setupForeignThreadGc): setupForeignThreadGc() - body - when declared(tearDownForeignThreadGc): - tearDownForeignThreadGc() + try: + body + finally: + when declared(tearDownForeignThreadGc): + tearDownForeignThreadGc() var activeMappingsLock: Lock var activeMappings {.guard: activeMappingsLock.}: Table[cint, MappingHandle]