def __init__(self, fh, map=None, maxdata=None, ignore_broken_pipe=False, logger=None, **obsopt):
"""Wrap a dispatcher around the passed filehandle.
If `ignore_broken_pipe` is `True`, an `EPIPE` or `EBADF` error will
call `handle_close()` instead of `handle_expt()`. Useful when broken
pipes should be handled quietly.
`logger` is a logger which will be used to log unusual exceptions;
otherwise, they will be printed to stderr.
"""
self.maxdata = maxdata if maxdata else self.pipe_maxdata
self.__logger = logger
if ignore_broken_pipe:
self.__ignore_errno = [EPIPE, EBADF]
else:
self.__ignore_errno = []
self.__filehandle = fh
# Check for overduplication of the file descriptor and close the extra
fddup = os.dup(fh.fileno())
file_dispatcher.__init__(self, fddup, map=map)
if (self._fileno != fddup): os.close (fddup)
Observable.__init__(self, **obsopt)
评论列表
文章目录