Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python3-module-altrepo
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Unitsaev
python3-module-altrepo
Commits
09422da1
Verified
Commit
09422da1
authored
Apr 03, 2026
by
Kirill Unitsaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: add async context manager support
parent
8574c6eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
README.md
README.md
+6
-13
__init__.py
altrepo/__init__.py
+7
-0
No files found.
README.md
View file @
09422da1
...
...
@@ -27,14 +27,10 @@ from altrepo import ALTRepo
from
altrepo.api.types
import
Branch
async
def
main
():
client
=
ALTRepo
()
await
client
.
init
()
result
=
await
client
.
api
.
package
.
package_info
(
"firefox"
,
branch
=
Branch
.
sisyphus
)
pkg
=
result
.
packages
[
0
]
print
(
f
"{pkg.name} {pkg.version}-{pkg.release}"
)
await
client
.
close
()
async
with
ALTRepo
()
as
client
:
result
=
await
client
.
api
.
package
.
package_info
(
"firefox"
,
branch
=
Branch
.
sisyphus
)
pkg
=
result
.
packages
[
0
]
print
(
f
"{pkg.name} {pkg.version}-{pkg.release}"
)
asyncio
.
run
(
main
())
```
...
...
@@ -170,14 +166,11 @@ config = ALTRepoConfig(
client
=
ALTRepo
(
config
=
config
)
```
Если в вашем приложении уже есть
`aiohttp.ClientSession`
, её можно передать при инициализации
, чтобы не создавать лишних соединений
:
Если в вашем приложении уже есть
`aiohttp.ClientSession`
, её можно передать при инициализации:
```
python
import
aiohttp
session
=
aiohttp
.
ClientSession
()
client
=
ALTRepo
()
await
client
.
init
(
session
=
session
)
await
client
.
init
(
session
=
existing_
session
)
```
## Лицензия
...
...
altrepo/__init__.py
View file @
09422da1
...
...
@@ -28,5 +28,12 @@ class ALTRepo:
async
def
close
(
self
):
await
self
.
_session
.
close
()
async
def
__aenter__
(
self
):
await
self
.
init
()
return
self
async
def
__aexit__
(
self
,
*
args
):
await
self
.
close
()
__all__
=
(
"ALTRepo"
,
"ALTRepoConfig"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment