Skip to content

self.message_buffer is a Queue object. In Python, a Queue instance is always truthy regardless of whether it's empty, so the check if self.message_buffer: never evaluates to False. #2411

@Precious-Neche

Description

@Precious-Neche

Describe the bug
self.message_buffer is a Queue object. In Python, a Queue instance
is always truthy regardless of whether it's empty, so the check
if self.message_buffer: never evaluates to False.

To Reproduce

  • Run any config that uses the TwitterInput plugin
  • The buffer check on line ~13777 of twitter.py always passes
  • get_nowait() is called even on an empty queue, relying on the
    Empty exception as control flow rather than an intentional guard

Expected behavior
The code should check if not self.message_buffer.empty(): to
properly guard the get_nowait() call.

System Information (please complete the following information):

  • Operating System: [Windows 10]
  • Python Version: [e.g. v3.11]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions