[go: up one dir, main page]

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

dash_duo.server.stop() kills threads that it doesn't own - ones that were created after its inception #2704

Open
jake-bickle opened this issue Nov 29, 2023 · 0 comments
Labels
bug something broken P3 backlog

Comments

@jake-bickle
Copy link
jake-bickle commented Nov 29, 2023

Describe your context

dash                 2.14.1
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
dash-testing-stub    0.0.2

Describe the bug

KillerThread kills all threads that were created since the server's inception. This appears to be intended, but it shouldn't be. Dash should only modify threads that it has created.

Execute pytest -sv on the following example:

import dash
from dash import html

import threading
import time

def some_function_on_a_different_thread():
    try:
        print("starting long work")
        time.sleep(5)
        print("ending long work")
    except SystemExit:
        print("Thread received SystemExit.")


def test_some_function(dash_duo):
    app = dash.Dash(__name__)
    app.layout = html.Div(id="nully-wrapper", children=0)

    dash_duo.start_server(app)
    time.sleep(1)

    # This function could interact with the webpage, or do some other important work
    # in the background.
    my_thread = threading.Thread(target=some_function_on_a_different_thread)
    my_thread.start()

    dash_duo.server.stop()

This is a rather contrived example, but I have pytest fixtures that spin up services that must last between tests, all of whom may or may not create their own threads throughout the session's lifetime.

Expected behavior
Test should hang for ~5 seconds, and then "ending long work" is printed.

Actual behavior
Test lasts ~1 second, and "Thread received SystemExit." is printed.

@gvwilson gvwilson self-assigned this Jul 25, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog bug something broken labels Aug 13, 2024
@gvwilson gvwilson changed the title [BUG] dash_duo.server.stop() kills threads that it doesn't own - ones that were created after its inception dash_duo.server.stop() kills threads that it doesn't own - ones that were created after its inception Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants