Even though the code itself looks correct most likely it will not send any signals. Here Emit() does not actually send a message to the bus, it just queues the message to be sent by a separate goroutine. But there is no guarantee that the message will be sent before program terminates.
conn.Close() closes dbus connection but does not synchronize with outWorker(). Out channel may or may not be empty after Close() and so messages may or may not be sent.
The suggested solution is to add synchronization between Close() and outWorker() so that Close() awaits termination of outWorker() and so guarantees that all outbound signals as well as NoReplyExpected calls are sent to the bus.
Consider the following code that tries to send a signal:
Even though the code itself looks correct most likely it will not send any signals. Here Emit() does not actually send a message to the bus, it just queues the message to be sent by a separate goroutine. But there is no guarantee that the message will be sent before program terminates.
conn.Close() closes dbus connection but does not synchronize with outWorker(). Out channel may or may not be empty after Close() and so messages may or may not be sent.
The suggested solution is to add synchronization between Close() and outWorker() so that Close() awaits termination of outWorker() and so guarantees that all outbound signals as well as NoReplyExpected calls are sent to the bus.