jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/972505 )
Change subject: [IMPR] Handle canary events in comms.eventstreams ...................................................................... [IMPR] Handle canary events in comms.eventstreams Handle canary events coming from the Event Platform. Canary events are periodically sent to check if a stream is working. They contain bogus data, and should be filtered out by default. See https://w.wiki/7$2z and https://w.wiki/7$2v for specifics. This adds a `canary` parameter which enables receiving canary events. By default, this is set to `False` (canary events are filtered out). End users can choose to enable this to ensure that they are still receiving events from EventStreams. Bug: T350756 Change-Id: Ic7715f5a63af1b00f3a948ce7065373c20cab90d --- M pywikibot/comms/eventstreams.py 1 file changed, 27 insertions(+), 0 deletions(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/comms/eventstreams.py b/pywikibot/comms/eventstreams.py index 66cba5f..676acbc 100644 --- a/pywikibot/comms/eventstreams.py +++ b/pywikibot/comms/eventstreams.py @@ -112,6 +112,8 @@ def __init__(self, **kwargs) -> None: """Initializer. + :keyword bool canary: if True, include canary events, see + https://w.wiki/7$2z for more info :keyword APISite site: a project site object. Used if no url is given :keyword pywikibot.Timestamp or str since: a timestamp for older @@ -143,6 +145,8 @@ 'install it with "pip install sseclient"\n') self.filter = {'all': [], 'any': [], 'none': []} self._total = None + self._canary = kwargs.pop('canary', False) + try: self._site = kwargs.pop('site') except KeyError: # T335720 @@ -306,6 +310,9 @@ :param data: event data dict used by filter functions """ + if not self._canary and data.get('meta', {}).get('domain') == 'canary': + return False # T266798 + if any(function(data) for function in self.filter['none']): return False if not all(function(data) for function in self.filter['all']): -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/972505 To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: Ic7715f5a63af1b00f3a948ce7065373c20cab90d Gerrit-Change-Number: 972505 Gerrit-PatchSet: 3 Gerrit-Owner: Chlod Alejandro <[email protected]> Gerrit-Reviewer: Xqt <[email protected]> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
_______________________________________________ Pywikibot-commits mailing list -- [email protected] To unsubscribe send an email to [email protected]
