python3 socket reading, avoid while True or best practice

Rajesh Rajendran

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.

J_H

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

decode content while reading from socket in Python

From Dev

What is best practice for reading all bytes from tcp socket in windows phone?

From Dev

What is best practice for reading all bytes from tcp socket in windows phone?

From Dev

Reading application settings best practice

From Dev

Why while(true) is bad practice?

From Dev

Best practice for structuring module exceptions in Python3

From Dev

Best pythonic practice to avoid repeating code?

From Dev

Best Practice to avoid using 'ifs' for calling methods

From Dev

Best practice with caching. Avoid redundant caching?

From Dev

git best practice and avoid cherry picking

From Dev

Best pythonic practice to avoid repeating code?

From Dev

Best practice with caching. Avoid redundant caching?

From Dev

Avoid DIV inside SPAN - Best Practice

From Dev

Best Practice For Reading Form Data in React

From Dev

Best practice for ethernet communication using socket

From Dev

Best practice for ethernet communication using socket

From Java

Best practice for Python assert

From Dev

Socket InputStream glitches while reading bytes in chunks

From Dev

break condition while reading from socket

From Dev

Clarifications while reading/writing Java socket streams

From Dev

Best practice to avoid null-check conditional operator boilerplate

From Dev

What is the best practice to set parameters to object and avoid duplicated code?

From Dev

Best practice to avoid double request from View in ASP.NET

From Dev

Laravel Eloquent best practice reading entries including relationships

From Dev

Best practice for secureing an existing socket connection, without SSL

From Dev

Python 3 best practice argument order

From Dev

Python 3 best practice argument order

From Dev

Python and Pygame inspiration and best practice

From Dev

best practice regarding encapsulation python

Related Related

  1. 1

    decode content while reading from socket in Python

  2. 2

    What is best practice for reading all bytes from tcp socket in windows phone?

  3. 3

    What is best practice for reading all bytes from tcp socket in windows phone?

  4. 4

    Reading application settings best practice

  5. 5

    Why while(true) is bad practice?

  6. 6

    Best practice for structuring module exceptions in Python3

  7. 7

    Best pythonic practice to avoid repeating code?

  8. 8

    Best Practice to avoid using 'ifs' for calling methods

  9. 9

    Best practice with caching. Avoid redundant caching?

  10. 10

    git best practice and avoid cherry picking

  11. 11

    Best pythonic practice to avoid repeating code?

  12. 12

    Best practice with caching. Avoid redundant caching?

  13. 13

    Avoid DIV inside SPAN - Best Practice

  14. 14

    Best Practice For Reading Form Data in React

  15. 15

    Best practice for ethernet communication using socket

  16. 16

    Best practice for ethernet communication using socket

  17. 17

    Best practice for Python assert

  18. 18

    Socket InputStream glitches while reading bytes in chunks

  19. 19

    break condition while reading from socket

  20. 20

    Clarifications while reading/writing Java socket streams

  21. 21

    Best practice to avoid null-check conditional operator boilerplate

  22. 22

    What is the best practice to set parameters to object and avoid duplicated code?

  23. 23

    Best practice to avoid double request from View in ASP.NET

  24. 24

    Laravel Eloquent best practice reading entries including relationships

  25. 25

    Best practice for secureing an existing socket connection, without SSL

  26. 26

    Python 3 best practice argument order

  27. 27

    Python 3 best practice argument order

  28. 28

    Python and Pygame inspiration and best practice

  29. 29

    best practice regarding encapsulation python

HotTag

Archive