serialCommunicationServer.py 文件源码

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

项目:aws-iot-python 作者: vjammar 项目源码 文件源码
def accept(self):
        # Messages are passed from remote client to server line by line
        # A number representing the number of lines to receive will be passed first
        # Then serialCommunicationServer should loop the exact time to receive the following lines
        # All these reads add up tp ONE timeout: acceptTimeout. Once exceeded, this timeout will trigger a callback raising an exception
        # Throw acceptTimeoutException, ValueError
        # Store the incoming parameters into an internal data structure
        self._returnList = []
        self._log.writeLog("Clear internal list. Size: " + str(len(self._returnList)))
        signal.alarm(self._acceptTimeout)  # Enable SIGALRM
        self._log.writeLog("Accept-timer starts, with acceptTimeout: " + str(self._acceptTimeout) + " second(s).")
        numLines = int(self._basicInput())  # Get number of lines to receive
        self._log.writeLog(str(numLines) + " lines to be received. Loop begins.")
        loopCount = 1
        while(loopCount <= numLines):
            currElementIn = self._basicInput()
            self._returnList.append(currElementIn)
            self._log.writeLog("Received: " + str(loopCount) + "/" + str(numLines) + " Message is: " + currElementIn)
            loopCount += 1
        signal.alarm(0)  # Finish reading from remote client, disable SIGALRM
        self._log.writeLog("Finish reading from remote client. Accept-timer ends.")
        return self._returnList
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号