lnbase: lnbase_test must use threadsafe task submission
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
Derived from https://gist.github.com/AdamISZ/046d05c156aaeb56cc897f85eecb3eb8
|
Derived from https://gist.github.com/AdamISZ/046d05c156aaeb56cc897f85eecb3eb8
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import queue
|
||||||
import traceback
|
import traceback
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
@@ -398,14 +399,24 @@ class LNWorker:
|
|||||||
self.peer.open_channel()
|
self.peer.open_channel()
|
||||||
|
|
||||||
def blocking_test_run(self):
|
def blocking_test_run(self):
|
||||||
start = time.time()
|
try:
|
||||||
fut = asyncio.ensure_future(self._test())
|
start = time.time()
|
||||||
asyncio.get_event_loop().run_until_complete(fut)
|
q = queue.Queue()
|
||||||
fut.exception()
|
fut = asyncio.run_coroutine_threadsafe(self._test(q), asyncio.get_event_loop())
|
||||||
return "blocking test run took: " + str(time.time() - start)
|
exp = q.get(timeout=5)
|
||||||
|
if exp is not None: raise exp
|
||||||
|
return "blocking test run took: " + str(time.time() - start)
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
async def _test(self, q):
|
||||||
|
try:
|
||||||
|
await self.peer.channel_establishment_flow(self.wallet)
|
||||||
|
except Exception as e:
|
||||||
|
q.put(e)
|
||||||
|
else:
|
||||||
|
q.put(None)
|
||||||
|
|
||||||
async def _test(self):
|
|
||||||
await self.peer.channel_establishment_flow(self.wallet)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user