billy-yoyo / RainbowSixSiege-Python-API

Asynchronous python api for rainbow six siege (r6sapi)
MIT License
130 stars 31 forks source link

basic example fails #62

Closed soilstack closed 3 years ago

soilstack commented 3 years ago

Running python 3.7.3. Trying the basic example:

import asyncio
import r6sapi as api

@asyncio.coroutine
def run():
    auth = api.Auth("gino@mail.com", "secret_word")

    player = yield from auth.get_player("stone-flake", api.Platforms.UPLAY)
    operator = yield from player.get_operator("sledge")

    print(operator.kills)

asyncio.get_event_loop().run_until_complete(run())

throws:

C:\Users\r6>python sample.py 336 Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x000002A70E0E6FD0> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000002A70EA49390>, 108967.703)]', '[(<aiohttp.client_proto.ResponseHandler object at 0x000002A70EA58160>, 108968.687)]', '[(<aiohttp.client_proto.ResponseHandler object at 0x000002A70E9FB400>, 108969.234)]'] connector: <aiohttp.connector.TCPConnector object at 0x000002A70E9D9A20>

Not familiar w3ith asynio, so not sure where to even begin debugging. My login user/pwd pair is correct. If I try to login with intentionally bad credentials, I get a different fail:

r6sapi.exceptions.FailedToConnect: HTTP 401: Invalid credentials

Also, note, I pip install r6sapi into my conda environment. I saw that aiohttp was version 2.3.10. See in the git repository it's supposed to be >= 2.3.3. So I uninstalled, reinstalled it with 2.3.3 but I still get the identical error.

soilstack commented 3 years ago

Follow-up on this, it actually does return a result (printing the number of kills (336)). But still not sure about the 'unclosed connector' complaint.

billy-yoyo commented 3 years ago

To fix this use with api.Auth(...): or end your run() with an yield from auth.close(). Also I'd advise you use async/await rather than asyncio.courotine / yield from assuming you're using python 3.5+