Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples returning ERRORs #23

Open
recursos opened this issue Oct 19, 2024 · 5 comments
Open

Examples returning ERRORs #23

recursos opened this issue Oct 19, 2024 · 5 comments

Comments

@recursos
Copy link

Running the 1rst example in README:

"Exception has occurred: ClientConnectorError
Cannot connect to host cbk0.google.com:443 ssl:default [The semaphore timeout period has expired]
OSError: [WinError 121] The semaphore timeout period has expired

The above exception was the direct cause of the following exception:

File "D:\Hobby2024\GEO StreetView\streetlevel_00.py", line 4, in
streetview.download_panorama(pano, f"{pano.id}.jpg")
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host cbk0.google.com:443 ssl:default [The semaphore timeout period has expired]"

Running the 2nd example:
" File "D:\Hobby2024\GEO StreetView\streetlevel_async_00.py", line 4
async with ClientSession() as session:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'async with' outside async function"

Any sugestion?

@sk-zk
Copy link
Owner

sk-zk commented Oct 19, 2024

The sync example works fine for me, so this may be a network issue on your end.

The async examples in this repo are written with ipython in mind, where they will work as is. With the regular Python interpreter, as stated by the error message, the async code needs to be inside an async function, like this:

import asyncio
from streetlevel import streetview
from aiohttp import ClientSession


async def main():
    async with ClientSession() as session:
        pano = await streetview.find_panorama_async(46.883958, 12.169002, session)
        await streetview.download_panorama_async(pano, f"{pano.id}.jpg", session)


if __name__ == "__main__":
    asyncio.run(main())

@recursos
Copy link
Author

Thank you for your answer.
Edited the 2nd example (async), now it runs but I get the same error as for the 1rst example:

line 13, in
asyncio.run(main())
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host cbk0.google.com:443 ssl:default [The semaphore timeout period has expired]

@sk-zk
Copy link
Owner

sk-zk commented Oct 20, 2024

Can you ping cbk0.google.com? If yes, what's the latency like?

@recursos
Copy link
Author

Thank you for your answer.
This is the ping:

D:\Hobby2024\GEO StreetView>ping cbk0.google.com

Pinging cbk-legacy.l.google.com [216.58.215.174] with 32 bytes of data:
Reply from 216.58.215.174: bytes=32 time=21ms TTL=118
Reply from 216.58.215.174: bytes=32 time=21ms TTL=118
Reply from 216.58.215.174: bytes=32 time=21ms TTL=118
Reply from 216.58.215.174: bytes=32 time=21ms TTL=118

Ping statistics for 216.58.215.174:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 21ms, Maximum = 21ms, Average = 21ms

@recursos
Copy link
Author

While running example_1.py, to my surprise I found one image: "Km97D1NoYIySkjysrp8HMA.jpg"
in the downloads folder.

Encouraged by this, I retried 200 times using the command line:
D:\Hobby2024\GEO StreetView>for /l %N in (1 1 200) do py streetlevel_example1.py & echo %N
but no luck...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants