Need to wait for Google API but sleep function doesn't work

Solution 1:

You need to pass the function reference instead of calling it.

Change

sleep(5000, init());

to:

sleep(5000, init);