Skip to content

Commit

Permalink
replace print with logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
schelv committed Jan 12, 2024
1 parent 4a69635 commit d9ed165
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions githubkit/core.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from types import TracebackType
from contextvars import ContextVar
from asyncio import Event, BoundedSemaphore, sleep
Expand Down Expand Up @@ -478,21 +479,19 @@ async def arequest(
if retry_attempt_nr > self.config.max_nr_rate_limit_retry_attempts:
raise error

Check warning on line 480 in githubkit/core.py

View check run for this annotation

Codecov / codecov/patch

githubkit/core.py#L479-L480

Added lines #L479 - L480 were not covered by tests

# start_time = datetime.now()
# rate_limit_duration = error.retry_after
start_time = datetime.now()
rate_limit_duration = error.retry_after

Check warning on line 483 in githubkit/core.py

View check run for this annotation

Codecov / codecov/patch

githubkit/core.py#L482-L483

Added lines #L482 - L483 were not covered by tests

# print(f"retry request for {url} after {rate_limit_duration} seconds.")
# print(
# f"Started rate limit timer at {start_time} for
# {rate_limit_duration} seconds."
# )
logging.info(f"Encountered a rate limit for request for {url}.")
logging.info(

Check warning on line 486 in githubkit/core.py

View check run for this annotation

Codecov / codecov/patch

githubkit/core.py#L485-L486

Added lines #L485 - L486 were not covered by tests
f"Starting rate limit at {start_time}; not sending new request for {rate_limit_duration} seconds."
)
self.rate_limit_free.clear()
await sleep(error.retry_after.seconds)
self.rate_limit_free.set()
# print(
# f"rate limit that started at {start_time} stopped
# at {datetime.now()}"
# )
logging.info(

Check warning on line 492 in githubkit/core.py

View check run for this annotation

Codecov / codecov/patch

githubkit/core.py#L489-L492

Added lines #L489 - L492 were not covered by tests
f"Rate limit that started at {start_time} is stopped at {datetime.now()}."
)

return await self.arequest(

Check warning on line 496 in githubkit/core.py

View check run for this annotation

Codecov / codecov/patch

githubkit/core.py#L496

Added line #L496 was not covered by tests
method,
Expand Down

0 comments on commit d9ed165

Please sign in to comment.