Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
v2.0.4 Attempt to stabilize dev key rate limits
Browse files Browse the repository at this point in the history
  • Loading branch information
iann838 committed Nov 28, 2020
1 parent 929e452 commit 458853e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 22 deletions.
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -3,7 +3,7 @@

Pyot is a Python Framework for the Riot Games API, including League of Legends, Teamfight Tactics, Legends of Runeterra and Valorant that encourages rapid development and clean, pragmatic design. It specializes at doing task in async environment to get the expected result faster than synchronous code. Thanks for checking it out.

Pyot is highly inspired by [Cassiopeia](https://github.com/meraki-analytics/cassiopeia), you will notice that both has similar internal workings.
Pyot is highly inspired by [Cassiopeia](https://github.com/meraki-analytics/cassiopeia), you will notice that both has similar internal workings.

## Features

Expand Down Expand Up @@ -34,13 +34,13 @@ All documentation is in the "docs" directory and online at https://paaksing.gith
>
> Portal: https://paaksing.github.io/Pyot/
1. First, read **Core > Introduction > Installation Guide** for instructions on installing Pyot.
2. Next, follow the quick start guide in **Core > Introduction > Quick Start Guide** for creating and running your first Pyot project.
3. Then you should get to know the types of objects that Pyot works with in **Core > Cores > Objects**.
4. Now give yourself an idea of what models we have and what objects we work in **Models**
5. You'll probably want to read through the topical context managers for achieving concurrency in **Core > Cores > Gatherer** and **Core > Cores > Queue**.
6. From there you can jump back to manipulating the settings by reading **Core > Cores > Settings** and get to know all the available pipeline stores in Pyot at **Stores**.
7. Check out all the utils objects and methods available in `pyot.utils` that can be handy in your development, documented at **Utils > Methods** and **Utils > Objects**.
1. First, read the **[Installation Guide](https://paaksing.github.io/Pyot/core/installation.html)** for instructions on installing Pyot.
2. Next, follow the quick start guide in **[Quick Start Guide](https://paaksing.github.io/Pyot/core/startup.html)** for creating and running your first Pyot project.
3. Then you should get to know the types of objects that Pyot works with in **[Objects](https://paaksing.github.io/Pyot/core/apiobjects.html)**.
4. Now give yourself an idea of what models we have and what objects we work in **[Models](https://paaksing.github.io/Pyot/models/)**
5. You'll probably want to read through the topical context managers for achieving concurrency in **[Gatherer](https://paaksing.github.io/Pyot/core/gatherer.html)** and **[Queue](https://paaksing.github.io/Pyot/core/queue.html)**.
6. From there you can jump back to manipulating the settings by reading **Core > Cores > Settings** and get to know all the available pipeline stores in Pyot at **[Stores](https://paaksing.github.io/Pyot/stores/)**.
7. Check out all the utils objects and methods available in `pyot.utils` that can be handy in your development, documented at **[Utils](https://paaksing.github.io/Pyot/utils/)**.

Docs are updated rigorously. If you find any problems in the docs, or think they should be clarified in any way, please take 30 seconds to open an issue in this repository.

Expand Down
14 changes: 7 additions & 7 deletions docs/src/core/index.md
Expand Up @@ -32,13 +32,13 @@ All documentation is in the "docs" directory. If you're just getting started, he
> - **_Utils_** section documents the available helper functions and objects of Pyot.
> - **_Developers_** section has contributing guidelines and wanted features.
1. First, read **Core > Introduction > Installation Guide** for instructions on installing Pyot.
2. Next, follow the quick start guide in **Core > Introduction > Quick Start Guide** for creating and running your first Pyot project.
3. Then you should get to know the types of objects that Pyot works with in **Core > Cores > Objects**.
4. Now give yourself an idea of what models we have and what objects we work in **Models**
5. You'll probably want to read through the topical context managers for achieving concurrency in **Core > Cores > Gatherer** and **Core > Cores > Queue**.
6. From there you can jump back to manipulating the settings by reading **Core > Cores > Settings** and get to know all the available pipeline stores in Pyot at **Stores**.
7. Check out all the utils objects and methods available in `pyot.utils` that can be handy in your development, documented at **Utils > Methods** and **Utils > Objects**.
1. First, read the **[Installation Guide](installation.html)** for instructions on installing Pyot.
2. Next, follow the quick start guide in **[Quick Start Guide](startup.html)** for creating and running your first Pyot project.
3. Then you should get to know the types of objects that Pyot works with in **[Objects](apiobjects.html)**.
4. Now give yourself an idea of what models we have and what objects we work in **[Models](/models/)**
5. You'll probably want to read through the topical context managers for achieving concurrency in **[Gatherer](gatherer.html)** and **[Queue](queue.html)**.
6. From there you can jump back to manipulating the settings by reading **Core > Cores > Settings** and get to know all the available pipeline stores in Pyot at **[Stores](/stores/)**.
7. Check out all the utils objects and methods available in `pyot.utils` that can be handy in your development, documented at **[Utils](/utils/)**.

Docs are updated rigorously. If you find any problems in the docs, or think they should be clarified in any way, please take 30 seconds to open an issue in this repository.

Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
@@ -1,6 +1,6 @@
---
home: true
tagline: 2020 High level Python Framework for the Riot Games API, AsyncIO based, support for Django, wide range of Caches and the most perfect Rate Limiters.
tagline: AsyncIO based high level Python framework for the Riot Games API that encourages rapid development and clean, pragmatic design.
actionText: Documentations →
actionLink: /core/
features:
Expand Down
4 changes: 2 additions & 2 deletions docs/src/utils/index.md
Expand Up @@ -2,9 +2,9 @@

This module exposes a wide set of utils methods and objects **_highly_** helpful for development.

If you want to iterate for all the items in events, **_it would be innefficient_** doing `await event.item.get()` for every loop, even if it is cached, because Pyot's stores makes sure that any data is **_safe_** from any type of mutation, so stores will automatically copy the object before retrieving it, which adds up significant amount of CPU time. Solution would be a local cache that saves a reference to the object, one of the use case of a `PtrCache` from this module.
For example: If you want to iterate for all the items in lol timeline events, **_it would be innefficient_** doing `await event.item.get()` for every event, because Pyot's stores makes sure that all data is **_safe_** from any type of mutation, so stores will automatically serialize and deserialize when accessing the object, which adds up CPU time overall. The solution would be a local `PtrCache` that saves references to the object without serializing it.

Or if you want to convert a champion key to champion id without the need of pulling an entire `Champion` object then the method `champion_id_by_key` is here for you. There is also others common tools like the frequently mentioned `loop_run`, `fast_copy` which are even useful outside of Pyot environment.
Another example: Pyot objects are _self filled_, therefore having them in lists will start filling the object in that list, allocating more memory over time, with a `FrozenGenerator` it will isolate the objects from the list by returning a copy on the iteration process.

## Imports

Expand Down
7 changes: 7 additions & 0 deletions docs/src/utils/objects.md
Expand Up @@ -17,6 +17,13 @@ Starting v1.2.0
> ::: warning
> This cache will not copy the objects on get/put, modification to objects affects cached objects.
> :::
> ::: tip NEW
> **Since v2.0.0:** You can intercept the cache into the `get()` method of a Pyot Core object for syntax sugar.
> ```python
> cache = PtrCache()
> item = lol.Item(id=2003).get(ptr_cache=cache)
> ```
> :::
> ### `__init__(expiration=60*60*3, max_entries=2000)`
> - `expiration` <Badge text="param" type="warning" vertical="middle"/>: Expiration time of objects.
> - `max_entries` <Badge text="param" type="warning" vertical="middle"/>: Max number of objects before culling.
Expand Down
4 changes: 2 additions & 2 deletions pyot/limiters/core.py
Expand Up @@ -193,10 +193,10 @@ async def put_stream(self, fetched: dict, server: str, method: str, token: Limit
r_method_rate[i][0] = method_count[i][0]
for i in range(2):
if token.flag_app and r_app_time[i] < now:
app_top = date + timedelta(seconds=r_app_rate[i][3] + 1.6)
app_top = date + timedelta(seconds=r_app_rate[i][3] - 0.03)
r_app_time[i] = app_top
if token.flag_method and r_method_time[i] < now:
method_top = date + timedelta(seconds=r_method_rate[i][3] + 1.6)
method_top = date + timedelta(seconds=r_method_rate[i][3] - 0.03)
r_method_time[i] = method_top
await self.set_limits(server, method, [r_app_rate, r_app_time, r_method_rate, r_method_time])

Expand Down
2 changes: 1 addition & 1 deletion pyot/stores/riotapi.py
Expand Up @@ -80,7 +80,7 @@ async def _check_backoff(self, response: Any, server: str, regmethod: str, code:
if code == 429 and hasattr(response, "headers") and "X-Rate-Limit-Type" in response.headers and response.headers["X-Rate-Limit-Type"] != "service":
seconds = response.headers["Retry-After"] if "Retry-After" in response.headers else 5
LOGGER.warning(f"[Trace: {self._game.upper()} > RiotAPI] WARNING: The server responded with non service 429 Rate Limited, interrupts your task if this persists. "
f"Origin: {origin}, Inmediate backoff: {seconds} seconds.")
f"Origin: {origin}, Backing off for {seconds} seconds and retrying.")
type_ = response.headers["X-Rate-Limit-Type"]
await self._rate_limiter.inmediate_backoff(int(seconds), type_, server, regmethod)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -28,7 +28,7 @@

setup(
name="pyot",
version="2.0.3",
version="2.0.4",
author="Paaksing",
author_email="paaksingtech@gmail.com",
url="https://github.com/paaksing/Pyot",
Expand Down

0 comments on commit 458853e

Please sign in to comment.