Non so in Python, ma in C solitamente si usa dare recv finche i bytes ricevuti sono > 0