From 534a02bf09971703c98c372d76ffa26185ba92d5 Mon Sep 17 00:00:00 2001 From: Paul Wolneykien Date: Tue, 2 Apr 2024 00:33:49 +0300 Subject: [PATCH] Wrap the event stream generator into a function in order to run the initialization code immediately Signed-off-by: Paul Wolneykien --- icinga2apic/events.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/icinga2apic/events.py b/icinga2apic/events.py index bb07251..4e57c6c 100644 --- a/icinga2apic/events.py +++ b/icinga2apic/events.py @@ -82,5 +82,9 @@ def subscribe(self, payload, stream=True ) - for event in self._get_message_from_stream(stream): - yield event + + def gen(): + for event in self._get_message_from_stream(stream): + yield event + + return gen()