From eaacecf4a17d848a449c84970168161fc4890329 Mon Sep 17 00:00:00 2001 From: Jin Eguchi Date: Wed, 25 Nov 2020 05:39:30 +0900 Subject: [PATCH] Fix get_running_loop (python<3.7) (#6765) --- electrum/lnrater.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/electrum/lnrater.py b/electrum/lnrater.py index f84559183..744252981 100644 --- a/electrum/lnrater.py +++ b/electrum/lnrater.py @@ -11,8 +11,14 @@ from pprint import pformat from random import choices from statistics import mean, median, stdev from typing import TYPE_CHECKING, Dict, NamedTuple, Tuple, List +import sys import time +if sys.version_info[:2] >= (3, 7): + from asyncio import get_running_loop +else: + from asyncio import _get_running_loop as get_running_loop # noqa: F401 + from .logging import Logger from .util import profiler from .lnrouter import fee_for_edge_msat @@ -119,7 +125,7 @@ class LNRater(Logger): async def _analyze_graph(self): await self.channel_db.data_loaded.wait() self._collect_policies_by_node() - loop = asyncio.get_running_loop() + loop = get_running_loop() # the analysis is run in an executor because it's costly await loop.run_in_executor(None, self._collect_purged_stats) self._rate_nodes()