The fcntl module performs file and I/O control on UNIX file descriptors. File descriptors can be obtained using the fileno() method of a file or socket object.
fcntl(fd, cmd [, arg])
Performs a command, cmd, on an open file descriptor, fd. cmd is an integer command code. arg is an optional argument that’s either an integer or a string. If arg is passed as an integer, the return value of this function is an integer. If arg is a string, it’s interpreted as a binary data structure, and the return value of the call is the contents of the buffer converted back into a string object. In this case, the supplied argument and return value should be less than 1024 bytes to avoid possible data corruption. The following commands are available: