from jupyter/jupyter_client#941 (comment)
The SUB socket of the client can take time to connect to the IOPUB channel, and the client can miss important messages (especially those with the kernel status). The current workaround implemented in different clients is to "nudge" the kernel, i.e. send requests until the SUB socket is connected and able to receive the "idle" status message (i.e. having km.iopub_channel.msg_ready() returning True). You can find more detail in this issue.
and I think there's some other good examples that could be adopted from https://github.com/jupyter/jupyter_client/pull/592/files
e.g. this pattern
try:
await self.iopub_channel.get_msg(timeout=0.2)
except Empty:
pass