diff --git a/src/capport/utils/nft_socket.py b/src/capport/utils/nft_socket.py index 9cf2670..f2cae4b 100644 --- a/src/capport/utils/nft_socket.py +++ b/src/capport/utils/nft_socket.py @@ -91,8 +91,8 @@ class NFTSocket(pyroute2.netlink.nlsocket.NetlinkSocket): @contextlib.contextmanager def begin(self) -> typing.Generator[NFTTransaction, None, None]: + tx = NFTTransaction(socket=self) try: - tx = NFTTransaction(socket=self) yield tx # autocommit when no exception was raised # (only commits if it wasn't aborted)