There’s no exit strategy for your while loop, which effectively means that it loops forever, which is called an infinite loop, and should be prevented at all costs! If you want to run it for some time (but not forever), you could do something like this:
count = 0
if (count > 1000):
data, addr = serverSock.recvfrom(1024)
print "Message: ", data
count += 1
This loops 1001 times and then breaks out of the loop. You could even substitute the while with a for loop in this case.