gipc.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:gipc 作者: jgehrcke 项目源码 文件源码
def __repr__(self):
            """Based on original __repr__ from CPython 3.4's mp package.

            Reasons for re-implementing:

            * The original code would invoke os.waitpid() through
              _popen.poll(). This is forbidden in the context of gipc.
              This method instead reads the exitcode property which is set
              asynchronously by a libev child watcher callback.

            * The original code distinguishes 'initial' state from 'started'
              state. This is not necessary, as gipc starts processes right
              away.

            * This method removes the `if self is _current_process` check
              without changing output behavior (that's still 'started' status).
            """
            exitcodedict = multiprocessing.process._exitcode_to_name
            status = 'started'
            if self._parent_pid != os.getpid():
                status = 'unknown'
            elif self.exitcode is not None:
                status = self.exitcode
            if status == 0:
                status = 'stopped'
            elif isinstance(status, int):
                status = 'stopped[%s]' % exitcodedict.get(status, status)
            return '<%s(%s, %s%s)>' % (
                type(self).__name__,
                self._name,
                status,
                self.daemon and ' daemon' or ''
                )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号