pppd.py 文件源码

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

项目:hologram-python 作者: hologram-io 项目源码 文件源码
def connect(self, timeout = DEFAULT_CONNECT_TIMEOUT):

        self.proc = Popen(self._commands, stdout=PIPE, stderr=STDOUT, universal_newlines=True)

        # set stdout to non-blocking
        fd = self.proc.stdout.fileno()
        fl = fcntl.fcntl(fd, fcntl.F_GETFL)
        fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)

        result = [False]

        self._connectThread = threading.Thread(target = self.connectThreadedFunc,
                                               args = [result])
        self._connectThread.daemon = True
        self._connectThread.start()
        self._connectThread.join(timeout)

        # If thread is still alive, tear down pppd connection and kill the thread.
        if self._connectThread.is_alive():
            self._connectThread.join(1)
            self.proc.send_signal(signal.SIGTERM)
            time.sleep(1)

        return result[0]

    # EFFECTS: Establish a cellular connection. Returns true if successful,
    #          false otherwise.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号