(self)
| 114 | # and if needed ivoke the callback registered by the user for |
| 115 | # incoming messages. |
| 116 | def read_api_response(self): |
| 117 | try: |
| 118 | # Don't use await to read from the SSL socket (it's not |
| 119 | # supported). We put the socket in non blocking mode |
| 120 | # anyway. It will return None if there is no data to read. |
| 121 | nbytes = self.ssl.readinto(self.rbuf_mv[self.rbuf_used:],len(self.rbuf)-self.rbuf_used) |
| 122 | if self.debug: print("bytes from SSL socket:",nbytes) |
| 123 | except: |
| 124 | self.reconnect = True |
| 125 | return |
| 126 | |
| 127 | if nbytes != None: |
| 128 | if nbytes == 0: |
| 129 | self.reconnect = True |
| 130 | return |
| 131 | else: |
| 132 | self.rbuf_used += nbytes |
| 133 | if self.debug: print(self.rbuf[:self.rbuf_used]) |
| 134 | |
| 135 | # Check if we got a well-formed JSON message. |
| 136 | self.process_api_response() |
| 137 | |
| 138 | # Check if there is a well-formed JSON reply in the reply buffer: |
| 139 | # if so, parses it, marks the current request as no longer "pending" |
no test coverage detected