I have to write a simple tcp forwarder in python which will run for ever. I'll get data in 1 min intervals. So do I have to run the socket.read()
in while true
? Is there any better way to avoid all those unnecessary cpu-cycles? And one more thing, the socket.read() is in a thread.
do I have to run the socket.read() in while true? Is there any better way to avoid all those unnecessary cpu-cycles?
It's a blocking read()
. So your process (thread) is essentially sleeping while awaiting the next network communication, rather than consuming CPU cycles.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments