OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.set_blocking() method in Python is used to set the blocking mode of the specified file descriptor. This method modifies the os.O_NONBLOCK flag. It sets the os.O_NONBLOCK flag for non-blocking mode and clears the os.O_NONBLOCK flag for blocking mode.
A file descriptor in blocking mode means that I/O system calls like read, write, or connect can be blocked by the system.
For example: If we call read system call on stdin then our program will get blocked (the kernel will put the process into the sleeping state) until data to be read is actually available on stdin.
os.set_blocking() method is available on Unix platforms only.
Syntax: os.set_blocking(fd, blocking)
fd: A file descriptor whose blocking mode is to be set.
blocking: A Boolean value. True if the file descriptor is to be put into blocking mode and false if the file descriptor is to be put into non-blocking mode.
Return Type: This method does not return any value.
os.set_blocking()method to set the blocking mode of a file descriptor.
Blocking Mode: True Blocking mode changed Blocking Mode: False
- class method vs static method in Python
- Python | os.dup() method
- Python | set() method
- Python | next() method
- Python | os.WSTOPSIG() method
- Python | os.write() method
- Python | os.read() method
- Python | os.dup2() method
- Python | os.renames() method
- Python | os.closerange() method
- Python | cmath.exp() method
- Python | os.close() method
- Python | cmath.log() method
- Python | os.statvfs() method
- Python | os.WCOREDUMP() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.