Skip to content

Commit f47bb91

Browse files
committed
Fix asyncio handling in earlier versions of python
1 parent 569ed24 commit f47bb91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/analyzeMFT/mft_analyzer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def __init__(self, mft_file: str, output_file: str, debug: int = 0, verbosity: i
5252
self.csv_writer = None
5353
self.sqlite_writer = None
5454
self.hash_processor = None
55-
self.interrupt_flag = asyncio.Event()
55+
self._interrupt_flag = None
5656
self.logger = logging.getLogger('analyzeMFT.analyzer')
5757

5858
self.setup_logging()
5959
self.setup_interrupt_handler()
60-
60+
6161
self.mft_records: Dict[int, MftRecord] = {}
6262
self.current_chunk: List[MftRecord] = []
6363
self.chunk_count = 0
@@ -78,6 +78,13 @@ def __init__(self, mft_file: str, output_file: str, debug: int = 0, verbosity: i
7878
'unique_crc32': set(),
7979
})
8080

81+
@property
82+
def interrupt_flag(self):
83+
"""Lazily create interrupt flag when needed"""
84+
if self._interrupt_flag is None:
85+
self._interrupt_flag = asyncio.Event()
86+
return self._interrupt_flag
87+
8188
def setup_logging(self) -> None:
8289
if self.debug >= 2:
8390
self.logger.setLevel(logging.DEBUG)

0 commit comments

Comments
 (0)