luissilva1044894 / Pyrez

(ON REWRITE) An easy to use (a)sync wrapper for Hi-Rez Studios API (Paladins, Realm Royale, and Smite), written in Python. 🐍
http://pyrez.rtfd.io
MIT License
26 stars 11 forks source link

Function not awaited #15

Closed TECHNOFAB11 closed 5 years ago

TECHNOFAB11 commented 5 years ago

Describe the bug As soon as i call, for example, getDataUsed(), i get an error that the couroutine was never awaited. I found the problem, an await is missing. Snippet: https://github.com/luissilva1044894/Pyrez/blob/fe0a1e7daa8878b72bcb036f5c5776feb08cdd96/pyrez/api/API.py#L149

To Reproduce Try await getDataUsed()

Expected behavior Getting the data used

Screenshots

List your Python, Pyrez, and requests versions. If possible, check if this issue is already fixed in the repository:

Additional context Should be fixed by simply adding an await before the call

luissilva1044894 commented 5 years ago

Yo, @TECHNOFAB11. Thanks for your issue!

I temporarily stopped fixing/converting the master code to be async. I'm slowly rewriting the whole code and trying to convert it both async and data rich-like.

The actual master is an old version of the old master. There was a comment about it: https://github.com/luissilva1044894/Pyrez/blob/fe0a1e7daa8878b72bcb036f5c5776feb08cdd96/pyrez/api/API.py#L150

However, I temp fix this issue. I advice you to manually do requests instead using the methods, example code below (But you can still use the models classes)

>>> import pyrez
>>> import asyncio
>>> fake_dev_id = 1004
>>> fake_auth_key = '23DF3C7E9BD14D84BF892AD206B6755C'
>>> async def main():
    async with pyrez.PaladinsAPI.Async(fake_dev_id, fake_auth_key) as pala:
        res = await pala.makeRequest('getplayer', ['feyrazzle'])
        player = pyrez.models.Paladins.Player(**res[0])
        print(player)#or return player      
>>> asyncio.get_event_loop().run_until_complete(main())

prints:

[{"ActivePlayerId": 572693, "Created_Datetime": "3/31/2016 7:57:47 PM", "HoursPlayed": 1296, "Id": 572693, "Last_Login_Datetime": "6/15/2019 5:01:50 PM", "Leaves": 27, "Level": 567, "Losses": 2559, "MasteryLevel": 40, "MergedPlayers": null, "Name": "FeyRazzle", "Personal_Status_Message": "", "Platform": "Steam", "RankedConquest": {"Leaves": 0, "Losses": 0, "Name": "Conquest", "Points": 0, "PrevRank": 0, "Rank": 0, "Season": 0, "Tier": 0, "Trend": 0, "Wins": 0, "player_id": null, "ret_msg": null}, "RankedController": {"Leaves": 0, "Losses": 0, "Name": "Ranked Controller", "Points": 0, "PrevRank": 0, "Rank": 0, "Season": 0, "Tier": 0, "Trend": 0, "Wins": 0, "player_id": null, "ret_msg": null}, "RankedKBM": {"Leaves": 2, "Losses": 49, "Name": "Ranked KBM", "Points": 37, "PrevRank": 191, "Rank": 191, "Season": 3, "Tier": 25, "Trend": 0, "Wins": 49, "player_id": null, "ret_msg": null}, "Region": "Latin America North", "TeamId": 0, "Team_Name": "", "Tier_Conquest": 0, "Tier_RankedController": 0, "Tier_RankedKBM": 25, "Total_Achievements": 55, "Total_Worshippers": 716242463, "Wins": 3912, "hz_gamer_tag": null, "hz_player_name": "FeyRazzle", "ret_msg": null}]

I'm keeping the issue open. So, let me know if you got any new issue or request!

Edit: The commit is https://github.com/luissilva1044894/Pyrez/commit/ec0c9370a4cfb495ea64def5b15a178bd880a626

TECHNOFAB11 commented 5 years ago

@luissilva1044894 Thanks for the fast reply! Ill try the manual requests method, gonna keep you updated

luissilva1044894 commented 5 years ago

@TECHNOFAB11 I've pull a "patch" https://github.com/luissilva1044894/Pyrez/commit/076c63c6ed0d741aad327ad7fa05363a2067adca. This could works fine, also no more needed to do manual requests.

TECHNOFAB11 commented 5 years ago

@luissilva1044894 Awesome! Ill check it out when i can. Thanks a lot!

TECHNOFAB11 commented 5 years ago

@luissilva1044894 as far as i tested, it seems to work fine!

luissilva1044894 commented 5 years ago

@TECHNOFAB11 I've tested too,,, Just some methods/calls could not works as well. E.g: testSession().

Can you tell me how / where are you using the async code? I've tried to convert to async/await later and just got stuck. But now, its seems working fine. Let keep the issue for some days, if you got any issue/crash, just report here.

luissilva1044894 commented 5 years ago

As it's being 3 days without activity, I'm closing this issue. Free feel to re-open or create a new if you got any issue!