This fixes the problem
import os import sys import termios import fcntl
import os
import sys
import termios
import fcntl
self.fd = sys.stdin.fileno()
# Stop resetting the arduino on serial connect
self.newattr = termios.tcgetattr(self.fd)
self.newattr[2] = self.newattr[2] & ~termios.HUPCL
termios.tcsetattr(self.fd, termios.TCSANOW, self.newattr)