Skip to content

Commit 0f53e1d

Browse files
committed
feat: add asynchronous setup for webserver and transporter, and update dependencies for RabbitMQ and Uvicorn
1 parent bc0521a commit 0f53e1d

File tree

4 files changed

+87
-6
lines changed

4 files changed

+87
-6
lines changed

main.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
#!/usr/bin/env python3
2-
32
import logging
43
import os
54
from pathlib import Path
65
from typing import Dict
6+
import asyncio
77

8+
async def setup_webserver() -> None:
9+
"""Setup web server configuration."""
10+
# Placeholder for web server setup logic
11+
from src.modules.api import server
12+
await server()
813

9-
def main() -> None:
14+
async def setup_transporter() -> None:
15+
"""Setup transporter configuration."""
16+
# Placeholder for transporter setup logic
17+
# import src.modules.
18+
import src.modules.transporter
19+
20+
async def main() -> None:
1021
"""Main application entry point."""
1122
try:
1223
print("Start app...")
13-
import src.modules.api
24+
# import src.modules.transporter
25+
task1 = asyncio.create_task(setup_webserver())
26+
task2 = asyncio.create_task(setup_transporter())
27+
await asyncio.gather(task1, task2)
28+
print("App started successfully.")
29+
30+
1431

1532
except Exception as e:
1633
logging.error(f"Application failed to start: {e}", exc_info=True)
1734
raise
1835

1936

2037
if __name__ == "__main__":
21-
main()
38+
asyncio.run(main())

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ dependencies = [
88
"fastapi[standard]>=0.115.8",
99
"ipykernel>=6.29.5",
1010
"numpy>=2.2.3",
11+
"pika>=1.3.2",
1112
"pytest>=8.3.4",
13+
"rabbitmq>=0.2.0",
14+
"uvicorn>=0.34.0",
1215
]
1316

1417
[tool.black]

shell.nix

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
let
4+
# Common environment variables
5+
envVars = {
6+
NODE_ENV = "development";
7+
};
8+
9+
in pkgs.mkShell {
10+
buildInputs = with pkgs; [
11+
docker
12+
docker-compose
13+
nodejs_18
14+
nodePackages.ts-node
15+
];
16+
17+
shellHook = ''
18+
echo "Sync packages"
19+
uv sync
20+
21+
# Activate venv
22+
if [ -d ".venv" ]; then
23+
source .venv/bin/activate
24+
else
25+
echo "Virtual environment not found, creating one..."
26+
fi
27+
28+
alias dev='python3 main.py'
29+
alias python='python3'
30+
31+
which python3
32+
33+
'';
34+
}

uv.lock

Lines changed: 29 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)