File: stdio_checks.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (16 lines) | stat: -rw-r--r-- 324 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import fcntl
import os
import sys


def shout_stdout(size):
    sys.stdout.write('A' * size)
    return 'success'


def file_is_blocking(fobj):
    return not (fcntl.fcntl(fobj.fileno(), fcntl.F_GETFL) & os.O_NONBLOCK)


def stdio_is_blocking():
    return [file_is_blocking(f) for f in [sys.stdin, sys.stdout, sys.stderr]]