Fix uncaught exception when there are no connections to write to

More small Writer changes.

`random.choice()` throws an error with empty lists, and this was not caught, preventing your callback from being called when there are no connections.