Skip to content

Commit b878cd6

Browse files
committed
docs(README): Add async section
why: Make async APIs discoverable from project landing page what: - Add "Async Support" section with examples - Show basic AsyncGitSync usage - Show concurrent clone pattern with asyncio.gather
1 parent 2f14689 commit b878cd6

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,46 @@ def test_my_git_tool(
149149
assert (checkout_path / ".git").is_dir()
150150
```
151151

152+
### 5. Async Support
153+
Run VCS operations asynchronously for better concurrency when managing multiple repositories.
154+
155+
[**Learn more about Async Support**](https://libvcs.git-pull.com/topics/asyncio.html)
156+
157+
```python
158+
import asyncio
159+
import pathlib
160+
from libvcs.sync._async.git import AsyncGitSync
161+
162+
async def main():
163+
repo = AsyncGitSync(
164+
url="https://github.com/vcs-python/libvcs",
165+
path=pathlib.Path.cwd() / "libvcs",
166+
)
167+
await repo.obtain()
168+
await repo.update_repo()
169+
170+
asyncio.run(main())
171+
```
172+
173+
Clone multiple repositories concurrently:
174+
175+
```python
176+
import asyncio
177+
from libvcs.sync._async.git import AsyncGitSync
178+
179+
async def clone_all(repos: list[tuple[str, str]]):
180+
tasks = [
181+
AsyncGitSync(url=url, path=path).obtain()
182+
for url, path in repos
183+
]
184+
await asyncio.gather(*tasks) # All clone in parallel
185+
186+
asyncio.run(clone_all([
187+
("https://github.com/vcs-python/libvcs", "./libvcs"),
188+
("https://github.com/vcs-python/vcspull", "./vcspull"),
189+
]))
190+
```
191+
152192
## Project Information
153193

154194
- **Python Support**: 3.10+

0 commit comments

Comments
 (0)