Ah sorry, I probably should have been clearer what was going on during what I ellipses-ed out. The last 3 lines of code are actually occurring in a separate function that received the previously socket “ws” as a parameter (“sock”).
Additionally these are traditional socket objects rather than websockets, “ws” was shorthand for “whisper socket” when I was trying to use a separate socket connection to send the whispers. I can see how that would be misleading though!