Skip to content

Commit

Permalink
fix: remove blocking uvicorn.run call
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvis8x7b committed Feb 22, 2024
1 parent 1586ff4 commit 62cb494
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions main_miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@

async def main():
miner = Factory.get_miner()
config = Factory.get_config()
config = uvicorn.Config(
app=app,
host="0.0.0.0",
port=Factory.get_config().api.port,
workers=1,
log_level="info",
reload=False,
)
server = uvicorn.Server(config)
with miner as m:
log_task = asyncio.create_task(log_miner_status())

config = uvicorn.run(
app=app,
host="0.0.0.0",
port=config.api.port,
workers=1,
log_level="info",
# NOTE should only be used in development.
reload=False,
)

await server.serve()
# once the server is closed, cancel the logging task
log_task.cancel()
try:
Expand Down

0 comments on commit 62cb494

Please sign in to comment.