mirror of
https://github.com/RGBCube/GitHubWrapper
synced 2025-05-18 15:05:08 +00:00
Add close method
This commit is contained in:
parent
ff98977edb
commit
33309288a2
2 changed files with 7 additions and 2 deletions
|
@ -372,7 +372,10 @@ class GHClient:
|
||||||
""":class:`float`: Returns the latency of the client."""
|
""":class:`float`: Returns the latency of the client."""
|
||||||
return await self.http.latency()
|
return await self.http.latency()
|
||||||
|
|
||||||
|
async def close(self) -> None:
|
||||||
|
"""Close the session."""
|
||||||
|
await self.http.session.close()
|
||||||
|
|
||||||
|
|
||||||
class Client(GHClient):
|
class Client(GHClient):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ from .exceptions import *
|
||||||
from .exceptions import GistNotFound, RepositoryAlreadyExists, MissingPermissions
|
from .exceptions import GistNotFound, RepositoryAlreadyExists, MissingPermissions
|
||||||
from .exceptions import FileAlreadyExists
|
from .exceptions import FileAlreadyExists
|
||||||
from .exceptions import ResourceAlreadyExists
|
from .exceptions import ResourceAlreadyExists
|
||||||
|
from .exceptions import Ratelimited
|
||||||
from .objects import User, Gist, Repository, File, bytes_to_b64
|
from .objects import User, Gist, Repository, File, bytes_to_b64
|
||||||
from .urls import *
|
from .urls import *
|
||||||
from . import __version__
|
from . import __version__
|
||||||
|
@ -45,7 +46,8 @@ async def on_req_start(
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Before-request hook to make sure we don't overrun the ratelimit."""
|
"""Before-request hook to make sure we don't overrun the ratelimit."""
|
||||||
# print(repr(session), repr(ctx), repr(params))
|
# print(repr(session), repr(ctx), repr(params))
|
||||||
pass
|
if session._rates.remaining in ('0', '1'): #type: ignore
|
||||||
|
raise Exception('Ratelimit exceeded')
|
||||||
|
|
||||||
|
|
||||||
async def on_req_end(session: aiohttp.ClientSession, ctx: SimpleNamespace, params: aiohttp.TraceRequestEndParams) -> None:
|
async def on_req_end(session: aiohttp.ClientSession, ctx: SimpleNamespace, params: aiohttp.TraceRequestEndParams) -> None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue