Fix random uvicorn error
This commit is contained in:
parent
1c9abd9e35
commit
80a27bc0db
@ -1,6 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Unit test file for rpc/api_server.py
|
Unit test file for rpc/api_server.py
|
||||||
"""
|
"""
|
||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta, timezone
|
from datetime import datetime, timedelta, timezone
|
||||||
@ -299,10 +300,6 @@ def test_api_UvicornServer(mocker):
|
|||||||
s = UvicornServer(uvicorn.Config(MagicMock(), port=8080, host='127.0.0.1'))
|
s = UvicornServer(uvicorn.Config(MagicMock(), port=8080, host='127.0.0.1'))
|
||||||
assert thread_mock.call_count == 0
|
assert thread_mock.call_count == 0
|
||||||
|
|
||||||
s.install_signal_handlers()
|
|
||||||
# Original implementation starts a thread - make sure that's not the case
|
|
||||||
assert thread_mock.call_count == 0
|
|
||||||
|
|
||||||
# Fake started to avoid sleeping forever
|
# Fake started to avoid sleeping forever
|
||||||
s.started = True
|
s.started = True
|
||||||
s.run_in_thread()
|
s.run_in_thread()
|
||||||
@ -318,10 +315,6 @@ def test_api_UvicornServer_run(mocker):
|
|||||||
s = UvicornServer(uvicorn.Config(MagicMock(), port=8080, host='127.0.0.1'))
|
s = UvicornServer(uvicorn.Config(MagicMock(), port=8080, host='127.0.0.1'))
|
||||||
assert serve_mock.call_count == 0
|
assert serve_mock.call_count == 0
|
||||||
|
|
||||||
s.install_signal_handlers()
|
|
||||||
# Original implementation starts a thread - make sure that's not the case
|
|
||||||
assert serve_mock.call_count == 0
|
|
||||||
|
|
||||||
# Fake started to avoid sleeping forever
|
# Fake started to avoid sleeping forever
|
||||||
s.started = True
|
s.started = True
|
||||||
s.run()
|
s.run()
|
||||||
@ -331,13 +324,10 @@ def test_api_UvicornServer_run(mocker):
|
|||||||
def test_api_UvicornServer_run_no_uvloop(mocker, import_fails):
|
def test_api_UvicornServer_run_no_uvloop(mocker, import_fails):
|
||||||
serve_mock = mocker.patch('freqtrade.rpc.api_server.uvicorn_threaded.UvicornServer.serve',
|
serve_mock = mocker.patch('freqtrade.rpc.api_server.uvicorn_threaded.UvicornServer.serve',
|
||||||
get_mock_coro(None))
|
get_mock_coro(None))
|
||||||
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
s = UvicornServer(uvicorn.Config(MagicMock(), port=8080, host='127.0.0.1'))
|
s = UvicornServer(uvicorn.Config(MagicMock(), port=8080, host='127.0.0.1'))
|
||||||
assert serve_mock.call_count == 0
|
assert serve_mock.call_count == 0
|
||||||
|
|
||||||
s.install_signal_handlers()
|
|
||||||
# Original implementation starts a thread - make sure that's not the case
|
|
||||||
assert serve_mock.call_count == 0
|
|
||||||
|
|
||||||
# Fake started to avoid sleeping forever
|
# Fake started to avoid sleeping forever
|
||||||
s.started = True
|
s.started = True
|
||||||
s.run()
|
s.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user