python273 / telegraph

Telegraph API wrapper | Telegra.ph
https://pypi.org/project/telegraph/
MIT License
289 stars 45 forks source link

Can we make configurable requests? #12

Closed Winely closed 6 years ago

Winely commented 6 years ago

Hi, I am using your package to generate telegraph automatically. I need to set the timeout for requests to avoid the process hanging/freezing. As I notice that you are using requests and it's configurable, can you expose some of the requests's APIs so that I make configured requests? Something like telegraph.create_page(url, **kwagrs) would be good. Thanks a lot!

python273 commented 6 years ago

You can use custom HTTPAdapter to do that. Here's an example from another package: https://github.com/python273/vk_api/blob/master/examples/proxies_timeout_retries.py#L6-L13

Then you can subclass Telegraph and override __init__, so it has: self._telegraph.session.mount('https://', MyHTTPAdapter(timeout=8))