Test Failed
Push — master ( 6e307a...a66109 )
by srz
02:58
created

to_blocking_mode()   A

Complexity

Conditions 2

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
import fcntl, os
2
from sys import stdout, stderr
3
4
def to_blocking_mode(channel):
5
    flags = fcntl.fcntl(channel, fcntl.F_GETFL)
6
    if flags & os.O_NONBLOCK:
7
        fcntl.fcntl(channel, fcntl.F_SETFL, flags & ~os.O_NONBLOCK)
8
        return True
9
    return False
10
11
if to_blocking_mode(stderr):
12
    stderr.writelines(["Reset STDERR to blocking"])
13
if to_blocking_mode(stdout):
14
    stderr.writelines(["Reset STDOUT to blocking"])
15