-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
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
"connect: Caller thread can't call this function" when a co-routine uses await internally #78149
Comments
CC @RandomShaper. #78000 might help :) |
Managed to work around the issue thanks to #78000, thanks! |
As far as I can tell, such usage of signals is not safe. See #74404 (comment). |
Same kind of errors - not projects related - I have when I use vscode and the
|
I am getting the same issues, this is ridiculous that it made it to stable. Would this be considered "unsafe" and require calling deferred or will awaiting a separate threaded path be patched in addition to this? E.g:
|
Godot version
Godot v4.1.beta (2d6b880)
System information
Arch Linux - Vulkan (Forward+)
Issue description
I have an async function, using the keyword await, like so:
And I have another script, that requires the result of this function, but from a thread:
This triggers an error in the debugger:
When removing
await job_completed
from the first script, the error does not occur.I suspect this comes from the recent thread safety PRs: the async keyword uses the signal.connect() function internally, which is no longer allowed from a thread without using call_deferred.
Is this a regression, am I using it wrong, or is it by design?
Steps to reproduce
await
keywordMinimal reproduction project
Minimal reproduction project: threaded_await_minimal_project.zip
minimal_scene.tscn
and run the project.Additional information:
This project generates random PhysicsRayQueries and sends them to a PhysicsHelper class. This class runs the queries during the _physics_process before saving the results.
In the current state, you can see the await keyword (from the
execute
function in physics_helper.gd) is completely ignored. The threaded function returns immediately after callingexecute
.The expected behavior is that it should wait for the signal
job_completed
before trying to print the results.The text was updated successfully, but these errors were encountered: