mehdisadeghi / clashogram

Clash of Clans war monitoring for telegram channels.
MIT License
26 stars 11 forks source link

Update api.py #33

Closed MaicolAntali closed 2 years ago

MaicolAntali commented 2 years ago

FIX: • Removed the Session() cause persist parameters across requests can cause some errors • Used a f string for pass the token in the authorization header

mehdisadeghi commented 2 years ago

@MaicolAntali thanks for your PR. Would you explain what is the problem you are having with the Session?

MaicolAntali commented 2 years ago

@mehdisadeghi The session object (according with the docs) persist certain parameters across requests. First at all, every time that the _call_api method is called, it creates a new session object. That means the session doesn't work in right way (if you creare a new object every time the persistent paramennter dones't exist)

I have try to run this code but after some request the API returns me an error. (i have verifyed the the token and endpoint was right). Once i have remoive the session object the problem doesn't not come up. Probably is because the code generate a new object every time is called the method _call_api so there are many session object (not used) that can have some conflict and overload the ram.

I have made some test there is not time improvement with the session or without session.

mehdisadeghi commented 2 years ago

@MaicolAntali thanks for elaborating. I found the reason I had added the Session in the first place. It was to retry requests. Since then I have removed retries, so the Session is totally unused. I'll merge right away.

MaicolAntali commented 2 years ago

@mehdisadeghi Perfect! Thank you 😊