Funkiness with signals and threads - bug or?

Godot Version



I am observing some unexpected behavior when emitting a signal from a thread. It seems that even if a listener is connected to the signal before the thread is started, the listener appears to not be connected to the signal when the signal is invoked from the thread.

extends Node2D

signal thread_work_done

func _ready():
	var t =

func _on_thread_work_done():
	print("thread_work_done listener invoked")

func thread_worker_func():
	print("thread work start")
	print("thread work signal emitted (listeners: %s) " % [thread_work_done.get_connections()])

In this example, the listener function is never invoked, and the final print statement shows that it is not yet connected.

I don’t know for sure but you are putting the thread on the stack, the ref could be removed(out of scope), so the signal is actually gone and not registered.

Try making it a field instead. (no idea about the thread issue if it’s not this)

Just a guess.