From 31f82887f266367f07a90260cffd2244d96fb680 Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 4 Oct 2024 17:35:54 -0400 Subject: [PATCH] Show something useful from `EvtSubscribe_push` demo --- CHANGES.txt | 2 ++ win32/Demos/EvtSubscribe_push.py | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index fd800ca290..87a7216ec3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,8 @@ https://mhammond.github.io/pywin32_installers.html. Coming in build 308, as yet unreleased -------------------------------------- +* The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam) + Build 307, released 2024-10-04 ------------------------------ ### Release process changes diff --git a/win32/Demos/EvtSubscribe_push.py b/win32/Demos/EvtSubscribe_push.py index 519ef0d72c..fa4feb7290 100644 --- a/win32/Demos/EvtSubscribe_push.py +++ b/win32/Demos/EvtSubscribe_push.py @@ -1,4 +1,8 @@ ## Demonstrates a "push" subscription with a callback function +from __future__ import annotations + +from time import sleep + import win32evtlog query_text = '*[System[Provider[@Name="Microsoft-Windows-Winlogon"]]]' @@ -15,7 +19,7 @@ def c(reason, context, evt): return 0 -evttext = [] +evttext: list[str] = [] s = win32evtlog.EvtSubscribe( "System", win32evtlog.EvtSubscribeStartAtOldestRecord, @@ -23,3 +27,6 @@ def c(reason, context, evt): Callback=c, Context=evttext, ) + +sleep(0.001) +print("\n".join(evttext))