Skip to content

Commit 511aa0f

Browse files
committed
make main function async and add uv command to run async
1 parent c2eb3e0 commit 511aa0f

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dependencies = [
1515
"python-dotenv>=1.0.1",
1616
"scikit-learn>=1.6.1",
1717
"torch>=2.6.0",
18+
"tqdm>=4.67.1",
1819
"transformers>=4.49.0",
1920
"websockets>=15.0",
2021
]
@@ -32,6 +33,7 @@ package=true
3233

3334
[project.scripts]
3435
ingest = "client:main"
36+
ingest_async = "async_client:run"
3537

3638
[tool.setuptools.packages.find]
3739
where = ["src"]

src/async_client.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async def listen(url, valid_message_queue: asyncio.Queue):
8989
logger.error(f"Invalid WebSocket URI: {url}")
9090

9191

92-
def main():
92+
async def main():
9393
load_dotenv()
9494
logging.basicConfig(
9595
level=logging.INFO,
@@ -104,19 +104,19 @@ def main():
104104
classified_message_queue = asyncio.Queue()
105105
conversation_archival_queue = asyncio.Queue()
106106

107-
asyncio.gather(
107+
await asyncio.gather(
108108
listen(os.getenv("WS_SOCK"), valid_message_queue),
109109
classify_message(valid_message_queue, classified_message_queue),
110110
match_conversation(classified_message_queue, state),
111111
completed_conversations(conversation_archival_queue, state),
112112
store_probable_calendar_conversations(conversation_archival_queue),
113-
)
114-
115-
asyncio.gather(
116113
flush_all_conversations(conversation_archival_queue, state),
117-
store_probable_calendar_conversations(conversation_archival_queue),
118114
)
119115

120116

117+
def run():
118+
asyncio.run(main())
119+
120+
121121
if __name__ == "__main__":
122-
main()
122+
run()

0 commit comments

Comments
 (0)