fix failed apiserver tests
This commit is contained in:
parent
cd8455ccb7
commit
b949ea301c
@ -114,6 +114,10 @@ class ApiServer(RPCHandler):
|
|||||||
|
|
||||||
self._thread.join()
|
self._thread.join()
|
||||||
|
|
||||||
|
self._thread = None
|
||||||
|
self._loop = None
|
||||||
|
self._background_task = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def shutdown(cls):
|
def shutdown(cls):
|
||||||
cls.__initialized = False
|
cls.__initialized = False
|
||||||
@ -169,15 +173,15 @@ class ApiServer(RPCHandler):
|
|||||||
app.add_exception_handler(RPCException, self.handle_rpc_exception)
|
app.add_exception_handler(RPCException, self.handle_rpc_exception)
|
||||||
|
|
||||||
def start_message_queue(self):
|
def start_message_queue(self):
|
||||||
|
if self._thread:
|
||||||
|
return
|
||||||
|
|
||||||
# Create a new loop, as it'll be just for the background thread
|
# Create a new loop, as it'll be just for the background thread
|
||||||
self._loop = asyncio.new_event_loop()
|
self._loop = asyncio.new_event_loop()
|
||||||
|
|
||||||
# Start the thread
|
# Start the thread
|
||||||
if not self._thread:
|
self._thread = Thread(target=self._loop.run_forever)
|
||||||
self._thread = Thread(target=self._loop.run_forever)
|
self._thread.start()
|
||||||
self._thread.start()
|
|
||||||
else:
|
|
||||||
raise RuntimeError("Threaded loop is already running")
|
|
||||||
|
|
||||||
# Finally, submit the coro to the thread
|
# Finally, submit the coro to the thread
|
||||||
self._background_task = asyncio.run_coroutine_threadsafe(
|
self._background_task = asyncio.run_coroutine_threadsafe(
|
||||||
|
Loading…
Reference in New Issue
Block a user