enzet / map-machine

Python renderer for OpenStreetMap with custom icons intended to display as many map features as possible
MIT License
515 stars 34 forks source link

[Feature Request] Add proxy support #151

Open LaoshuBaby opened 1 year ago

LaoshuBaby commented 1 year ago

Looks like python3.11 will use system proxy automatically, but 3.9 still won't. And this is a package, if it haven't got this feature, I can't just left a --proxy https://localhost:port in parameters like what I'll do when install with pip.

That's because openstreetmap.org get blocked in some region, for example, where I'm living, China. So I need to visit it pass a proxy.

Now when I run map-machine tile --tile 13/6744/3103 it will throw this error:

  File "C:\Environment\Python\Python39\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.openstreetmap.org', port=443): Max retries exceeded with url: /api/0.6/map?bbox=116.366%2C39.909%2C116.412%2C39.944 (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000260FFF842B0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time'))

I noticed that the author enzet seems to have no time to contribute to open source projects recently, so I am trying to solve this problem in my fork, but I guess original author's review may be needed before merge that PR. (Hope it's not Squash or Rebase

Thank you for taking the time to read this issue


Edit: I found the issue itself https://github.com/python/cpython/issues/86793, and it was fixed in https://github.com/python/cpython/pull/26307 (3.11)