Your trouble is in this line:
thread2 = threading.Thread(target=Connection().getOnline("", 50007))
Here, you're actually calling Connection().getOnline("", 50007)
, which blocks. You haven't done this in the background, you've done it before your thread is started. You need to adjust your call to look like this:
thread2 = threading.Thread(target=Connection().getOnline, args = ("", 50007))