I'm wondering if there is a way to detect physical disconnection of a device while serial communication is open? Is the only way to write try-except code whenever data is sent?
There is no standard way to detect if a serial device is connected to say RS-232, RS-422, and other serial interfaces - there could be exceptions, which I don't know about though. For a RS-232 the minimum required wires to be able to receive and send are ground, TX, and RX. For a differential serial interface like RS-422 or RS-485 the ground isn't needed. If you know something about the behaviour of the device connected, then you could use this. Like if you expect certain responses to commands sent, or the RS-232 flags to be set in a certain way.
How to detect when a device is disconnected while serial communication is open?