Skip to content

Instantly share code, notes, and snippets.

@NeedPainkiller
Created April 9, 2018 15:23
Show Gist options
  • Save NeedPainkiller/3496433d979a4734469606435aac01fb to your computer and use it in GitHub Desktop.
Save NeedPainkiller/3496433d979a4734469606435aac01fb to your computer and use it in GitHub Desktop.
AWS ap-northeast-2 ping test
import uuid
import requests
import time
from rx import Observable
class AWS:
def check(self):
link = "http://dynamodb.ap-northeast-2.amazonaws.com/ping?x="
return Observable.interval(2000)\
.map(lambda i: uuid.uuid4().hex)\
.map(lambda hash: link+hash)\
.map(lambda req_link: requests.get(req_link))\
.on_error_resume_next(lambda e: Observable.just(e))\
.map(lambda res: res.elapsed.total_seconds())\
.map(lambda elapsed: int(round(elapsed, 3)*1000))
AWS().check().subscribe(on_next=lambda next: print(next))
input('press any key to exit\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment