-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
Thread remains in active state when function has finished #7235
Comments
When the thread is done, call |
Thanks, this workaround is good. |
Just realized that the message about the lost Thread object is printed only when you exit the application. |
It's not a workaround, if you fork off into a thread, you have to join it back into the main thread later to have it deallocated. That's what If you don't care about the return value, you can use something like |
Seems a bit pointless to have to wait for a thread. I mean you start a thread because you don't want to wait... |
Well, sometimes you need the return value from said thread, and might want to hang while it finishes rather than not. func _thread_func(params):
var done = do_stuff(with(params))
var result = do_more_stuff(with(done))
mutex.lock(); value = result; mutex.unlock()
# All done, updated on main thread, better to tell it to close the nonmain thread:
params.thread.call_deferred("wait_to_finish") # Execute on idle main thread |
Ahem. Is there something we should do about this, or should we leave it as-is? |
First of all thank you for your report and sorry for the delay. We released Godot 3.0 in January 2018 after 18 months of work, fixing many old issues either directly, or by obsoleting/replacing the features they were referring to. We still have hundreds of issues whose relevance/reproducibility needs to be checked against the current stable version, and that's where you can help us. For bug reports, please also make sure that the issue contains detailed steps to reproduce the bug and, if possible, a zipped project that can be used to reproduce it right away. This greatly speeds up debugging and bugfixing tasks for our contributors. Our Bugsquad will review this issue more in-depth in 15 days, and potentially close it if its relevance could not be confirmed. Thanks in advance. Note: This message is being copy-pasted to many "stale" issues (90+ days without activity). It might happen that it is not meaningful for this specific issue or appears oblivious of the issue's context, if so please comment to notify the Bugsquad about it. |
Hey, And actually, I am not understanding how the wait_to_finish function can work without freezing. |
I also run into this as well in Godot 3.1 alpha2, my thread function finishes to execute, but |
I've been working on adding |
@mihai-dragan Can you (or anyone else) still reproduce this bug in Godot 3.3 or any later release? If yes, please ensure that an up-to-date Minimal Reproduction Project (MRP) is included in this report (a MRP is a zipped Godot project with the minimal elements necessary to reliably trigger the bug). You can upload ZIP files in an issue comment with a drag and drop. |
I can confirm this still occurs - I have a heavy benchmarking task triggerable by a GUI button, and thus made it off thread and was originally checking if the thread was still |
I also can confirm it still occurs in v3.3.2 stable official. |
MInimal reproduction project: (just create a simple Node.tscn and attach this script to it and run)
|
Windows 7 64 bit - Godot v2.1.1 stable
Started a thread defined as global variable to my script:
var handler = Thread.new()
like this (from _process):
handler.start(self, "_handle_comm", connection)
At the end of _handle_comm function I print a message:
print("exit handler")
I see this message printed to stdout, but when I check the thread with is_active() it returns true.
In the output console (stdout/err) I see this message:
ERROR: Reference to a Thread object object was lost while the thread is still running..
At: core\bind\core_bind.cpp:2376
The text was updated successfully, but these errors were encountered: