From 860cb05b1c458651e4e28afda5dd8c2ac8ade94c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Sat, 26 Jun 2021 14:49:49 +0200
Subject: [PATCH] add CMS to VarlenIterator

---
 README.md          | 2 +-
 setup.cfg          | 2 +-
 tempsdb/varlen.pyx | 8 ++++++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index d0dc88c..6648276 100644
--- a/README.md
+++ b/README.md
@@ -51,7 +51,7 @@ Then copy your resulting wheel and install it via pip on the target system.
 
 ## v0.6.2
 
-* _TBA_
+* added the context manager syntax to VarlenIterator
 
 ## v0.6.1
 
diff --git a/setup.cfg b/setup.cfg
index 0fdfdde..1da8734 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,7 +1,7 @@
 # coding: utf-8
 [metadata]
 name = tempsdb
-version = 0.6.2a1
+version = 0.6.2a2
 long-description = file: README.md
 long-description-content-type = text/markdown; charset=UTF-8
 license_files = LICENSE
diff --git a/tempsdb/varlen.pyx b/tempsdb/varlen.pyx
index f17211b..964b246 100644
--- a/tempsdb/varlen.pyx
+++ b/tempsdb/varlen.pyx
@@ -289,6 +289,8 @@ cdef class VarlenIterator:
     If you forget to do that, a warning will be issued and the destructor will
     close it automatically.
 
+    Also supports the context manager syntax of :class:`~tempsdb.iterators.Iterator`
+
     :param parent: parent series
     :param start: started series
     :param stop: stopped series
@@ -388,6 +390,12 @@ cdef class VarlenIterator:
             else:
                 return varlen_entry.timestamp(), varlen_entry
 
+    def __enter__(self):
+        return self
+
+    def __exit__(self, exc_type, exc_val, exc_tb):
+        self.close()
+
     def __iter__(self):
         return self
 
-- 
GitLab