Skip to content
Snippets Groups Projects
Commit 9360efd8 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

2.14.42 added Closeable.closed

parent e5449e9e
No related branches found
No related tags found
No related merge requests found
# v2.14.42 # v2.14.42
* added `terminating` property to `TerminableThread` * added `terminating` property to `TerminableThread`
* added `Closeable.closed`
__version__ = '2.14.42a2' __version__ = '2.14.42'
...@@ -66,6 +66,13 @@ class Closeable: ...@@ -66,6 +66,13 @@ class Closeable:
def __init__(self): def __init__(self):
self.__finalized = False self.__finalized = False
@property
def closed(self) -> bool:
"""
:return: whether this object is closed
"""
return self.__finalized
def close(self) -> bool: def close(self) -> bool:
""" """
Check if the resource needs cleanup, and clean up this resource. Check if the resource needs cleanup, and clean up this resource.
......
...@@ -49,6 +49,7 @@ class TestCase(unittest.TestCase): ...@@ -49,6 +49,7 @@ class TestCase(unittest.TestCase):
a['test'] = True a['test'] = True
b = MyClose() b = MyClose()
self.assertFalse(b.closed)
del b del b
gc.collect() gc.collect()
self.assertTrue(a['test']) self.assertTrue(a['test'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment