Skip to content

Conversation

@filipchristiansen
Copy link
Contributor

Summary

This PR fixes thecoroutine 'main' was never awaited RuntimeWarning by introducing a synchronous Click command (main) that wraps an async function (_async_main) with asyncio.run(). This approach ensures that Click’s command decorators see a normal sync function, while the actual logic runs asynchronously (and is properly awaited).

Key Changes

  • Added _async_main(...) function for the actual async logic.
  • Updated the Click-decorated main(...) to be synchronous, which calls _async_main(...) via asyncio.run().
  • Removed the previous direct async def usage under Click’s command decorator.

Benefits

  • No more RuntimeWarning about un-awaited coroutines.
  • Cleaner separation of concerns between sync CLI handling and async operations.

May be related to #125.

- Change main() to a synchronous Click command
- Introduce _async_main() for async ingest logic
- Use asyncio.run(...) to properly await the async function
@cyclotruc cyclotruc merged commit 71b1167 into main Jan 17, 2025
8 checks passed
@cyclotruc cyclotruc deleted the refactor/cli-async-await branch January 17, 2025 16:10
RyanL2004 pushed a commit to RyanL2004/gitingest that referenced this pull request Jan 18, 2025
…mp-labs#136)

- Change main() to a synchronous Click command
- Introduce _async_main() for async ingest logic
- Use asyncio.run(...) to properly await the async function
FOLKS-Tech pushed a commit to FOLKS-Tech/gitingest that referenced this pull request Sep 5, 2025
…mp-labs#136)

- Change main() to a synchronous Click command
- Introduce _async_main() for async ingest logic
- Use asyncio.run(...) to properly await the async function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants