jenkins-bot merged this change.
[IMPR] ignore first empty warning of EventStreams
Bug: T244491
Change-Id: I6d7dfc2a2f0a77daf73ef1ce196b6ae52fd7855f
---
M pywikibot/comms/eventstreams.py
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py
index be5af0a..668c9b0 100644
--- a/pywikibot/comms/eventstreams.py
+++ b/pywikibot/comms/eventstreams.py
@@ -9,8 +9,8 @@
pip install sseclient
"""
#
-# (C) xqt, 2017-2018
-# (C) Pywikibot team, 2017-2019
+# (C) xqt, 2017-2020
+# (C) Pywikibot team, 2017-2020
#
# Distributed under the terms of the MIT license.
#
@@ -285,6 +285,7 @@
"""Iterator."""
n = 0
event = None
+ ignore_first_empty_warning = True
while self._total is None or n < self._total:
if not hasattr(self, 'source'):
self.source = EventSource(**self.sse_kwargs)
@@ -316,8 +317,10 @@
if self.streamfilter(element):
n += 1
yield element
- else:
+ elif not ignore_first_empty_warning:
warning('Empty message found.')
+ else:
+ ignore_first_empty_warning = False
elif event.event == 'error':
warning('Encountered error: {0}'.format(event.data))
else:
To view, visit change 570989. To unsubscribe, or for help writing mail filters, visit settings.