From 3ece48f745860d3569fe7212542821edbaedfc2d Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 4 Jun 2024 17:51:42 -0400 Subject: [PATCH] Show something useful from `EvtSubscribe_push` demo --- CHANGES.txt | 1 + win32/Demos/EvtSubscribe_push.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index c59bb5720b..7fc7f8c941 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -15,6 +15,7 @@ Coming in build 307, as yet unreleased -------------------------------------- ### pywin32 +* The `EvtSubscribe_push` demo now actually demonstrates the callback action and the event context being filled. (#2281, @Avasam) * Fixed accidentally trying to raise a `str` instead of an `Exception` in (#2270, @Avasam) * `Pythonwin/pywin/debugger/debugger.py` * `Pythonwin/pywin/framework/dlgappcore.py` 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))