|
7 | 7 | import os |
8 | 8 | import socket |
9 | 9 | import ssl |
10 | | -import sys |
11 | 10 | import threading |
12 | 11 | import weakref |
13 | 12 | from itertools import chain |
@@ -864,12 +863,10 @@ async def _ping_failed(self, error): |
864 | 863 |
|
865 | 864 | async def check_health(self): |
866 | 865 | """Check the health of the connection with a PING/PONG""" |
867 | | - if sys.version_info[0:2] == (3, 6): |
868 | | - func = asyncio.get_event_loop |
869 | | - else: |
870 | | - func = asyncio.get_running_loop |
871 | | - |
872 | | - if self.health_check_interval and func().time() > self.next_health_check: |
| 866 | + if ( |
| 867 | + self.health_check_interval |
| 868 | + and asyncio.get_running_loop().time() > self.next_health_check |
| 869 | + ): |
873 | 870 | await self.retry.call_with_retry(self._send_ping, self._ping_failed) |
874 | 871 |
|
875 | 872 | async def _send_packed_command(self, command: Iterable[bytes]) -> None: |
@@ -957,11 +954,8 @@ async def read_response(self, disable_decoding: bool = False): |
957 | 954 | raise |
958 | 955 |
|
959 | 956 | if self.health_check_interval: |
960 | | - if sys.version_info[0:2] == (3, 6): |
961 | | - func = asyncio.get_event_loop |
962 | | - else: |
963 | | - func = asyncio.get_running_loop |
964 | | - self.next_health_check = func().time() + self.health_check_interval |
| 957 | + next_time = asyncio.get_running_loop().time() + self.health_check_interval |
| 958 | + self.next_health_check = next_time |
965 | 959 |
|
966 | 960 | if isinstance(response, ResponseError): |
967 | 961 | raise response from None |
@@ -992,11 +986,8 @@ async def read_response_without_lock(self, disable_decoding: bool = False): |
992 | 986 | raise |
993 | 987 |
|
994 | 988 | if self.health_check_interval: |
995 | | - if sys.version_info[0:2] == (3, 6): |
996 | | - func = asyncio.get_event_loop |
997 | | - else: |
998 | | - func = asyncio.get_running_loop |
999 | | - self.next_health_check = func().time() + self.health_check_interval |
| 989 | + next_time = asyncio.get_running_loop().time() + self.health_check_interval |
| 990 | + self.next_health_check = next_time |
1000 | 991 |
|
1001 | 992 | if isinstance(response, ResponseError): |
1002 | 993 | raise response from None |
|
0 commit comments