Skip to content

Event Listener not triggering callbacks #1915

@pfranjo-unagi

Description

@pfranjo-unagi

Hello!

Using the example code from the Gazu documentation/github, I ran this:

def my_callback(event, data):
    print(f"event:{event}")
    print(f"data:{data}")

try:
    event_client = gazu.events.init()
    events = gazu.client.get("data/events/last?page_size=100")
    print(events)
    gazu.events.add_listener(event_client, "*", my_callback)
    gazu.events.run_client(event_client)

except KeyboardInterrupt:
    print("Stop listening.")
except TypeError:
    print("Authentication failed. Please verify your credentials.")

and it successfully connects to my Kitsu instance, and returns 'Listening to Kitsu Events...'
but the callback is never triggered for any events. I then attempted to run the listener and callback function in different threads, but the same result occurs. Here is the updated code:

def my_callback(data):
    print(f"Event received!")
    print(f"Data: {data}")

# Function to run the event listener in a separate thread
def run_event_listener():
    print("Starting event listener thread...")
    try:
        event_client = gazu.events.init()
        print("Event client initialized")
        
        # Listen to all events
        gazu.events.add_listener(event_client, "*", my_callback)
        print("Listener added for all events")
        
        print("Running event client (this blocks)...")
        gazu.events.run_client(event_client)
        
    except Exception as e:
        print(f"Error in event listener: {e}")

# Start event listener in a background thread
event_thread = threading.Thread(target=run_event_listener, daemon=True)
event_thread.start()
print("Event listener thread started")
print("Main program running. Press Ctrl+C to exit.")

try:
    # Keep the main thread alive
    while True:
        pass
except KeyboardInterrupt:
    print("\nStopping event listener...")

Let me know if I'm doing something wrong or if this is a bug!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions