Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug on Thread Example for show_editor() #324

Closed
dschiller opened this issue May 2, 2024 · 0 comments · Fixed by #325
Closed

Bug on Thread Example for show_editor() #324

dschiller opened this issue May 2, 2024 · 0 comments · Fixed by #325

Comments

@dschiller
Copy link

dschiller commented May 2, 2024

On page

https://spotify.github.io/pedalboard/reference/pedalboard.html#pedalboard.AudioUnitPlugin.show_editor

in the show_editor() Example it should be thread.start() not thread.run().

The Example:

import pedalboard
from threading import Event, Thread

plugin = pedalboard.load_plugin("../path-to-my-plugin-file")
close_window_event = Event()

def other_thread():
    # do something to determine when to close the window
    if should_close_window:
        close_window_event.set()

thread = Thread(target=other_thread)
thread.run()

# This will block until the other thread calls .set():
plugin.show_editor(close_window_event)

Corrected:

import pedalboard
from threading import Event, Thread

plugin = pedalboard.load_plugin("../path-to-my-plugin-file")
close_window_event = Event()

def other_thread():
    # do something to determine when to close the window
    if should_close_window:
        close_window_event.set()

thread = Thread(target=other_thread)
thread.start()

# This will block until the other thread calls .set():
plugin.show_editor(close_window_event)

The run() method is the entry point for the thread's activity, but calling it directly won't start the thread in a separate execution context.

@dschiller dschiller changed the title Bug on Thread Example Bug on Thread Example for show_editor() May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant