def daemonize(rootdir = "/", umask = 0, close_fds = False, dontclose = (),
              stdin = os.devnull, stdout = os.devnull, stderr = os.devnull,
              stdoutmode = 0644, stderrmode = 0644, pidfilename = None,
              defaultmaxfd = 1024):
    if not hasattr(dontclose, "__contains__"):
        if not isinstance(dontclose, int):
            raise TypeError, "dontclose must be an integer"
        dontclose = (int(dontclose),)
    else:
        for fd in dontclose:
            if not isinstance(fd, int):
                raise TypeError, "dontclose must contain only integers"
    # redirect stdin
    if stdin:
        fd = os.open(stdin, os.O_RDONLY)
        os.dup2(fd, 0)
        os.close(fd)
    # redirect stdout
    if stdout:
        fd = os.open(stdout, os.O_WRONLY | os.O_CREAT | os.O_APPEND,
                     stdoutmode)
        os.dup2(fd, 1)
        if (stdout == stderr):
            os.dup2(1, 2)
        os.close(fd)
    # redirect stderr
    if stderr and (stderr != stdout):
        fd = os.open(stderr, os.O_WRONLY | os.O_CREAT | os.O_APPEND,
                     stderrmode)
        os.dup2(fd, 2)
        os.close(fd)
    if os.fork():
        os._exit(0)                 # parent exits
    os.setsid()
    pid = os.fork()
    if pid:
        if pidfilename:
            try:
                f = open(pidfilename, "w")
                f.write("%s\n" % pid)
                f.close()
            except:
                pass
        os._exit(0)                 # parent exits
    if rootdir:
        os.chdir(rootdir)
    os.umask(umask)
    if close_fds:
        try:
            maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1]
            if maxfd == resource.RLIM_INFINITY:
                raise ValueError
        except:
            maxfd = defaultmaxfd
        for fd in xrange(3, maxfd):
            if fd in dontclose:
                continue
            try:
                os.close(fd)
            except:
                pass
Football data from English games since 1993. This downloads data from football-data.co.uk for the given season.
dataset/ETHPy150Open coreemu/core/daemon/core/misc/utils.py/daemonize--crossover with--dataset/ETHPy150Open SheffieldML/GPy/GPy/util/datasets.py/football_data