通过host获取到与此host相关的socket,本地会对socket进行缓存 :param host: :return:
(self, host)
| 70 | return result |
| 71 | |
| 72 | def _get_connection(self, host): |
| 73 | """ |
| 74 | 通过host获取到与此host相关的socket,本地会对socket进行缓存 |
| 75 | :param host: |
| 76 | :return: |
| 77 | """ |
| 78 | if not host or ':' not in host: |
| 79 | raise ValueError('invalid host {}'.format(host)) |
| 80 | if host not in self._connection_pool: |
| 81 | self.conn_lock.acquire() |
| 82 | try: |
| 83 | if host not in self._connection_pool: |
| 84 | self.client_heartbeats[host] = 0 |
| 85 | self._new_connection(host) |
| 86 | finally: |
| 87 | self.conn_lock.release() |
| 88 | return self._connection_pool[host] |
| 89 | |
| 90 | def _new_connection(self, host): |
| 91 | """ |
no test coverage detected