Skip to content

Instantly share code, notes, and snippets.

@funkyboy
Last active April 17, 2018 09:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save funkyboy/5bcbfc0cc0d821ddf9b73d6e7d70d367 to your computer and use it in GitHub Desktop.
Ably Python test
# To install
# sudo pip3 install ably
# sudo pip3 install schedule
# To run `python3 test.py`
from ably import AblyRest
import random
import schedule
import time
def publish():
client = AblyRest('YOUR_API_KEY')
random_string = str(random.randint(1,9999))
channel = client.channels.get('society:' + random_string)
print('publishing ', random_string)
channel.publish('event', random_string)
schedule.every(0.2).seconds.do(publish)
while 1:
schedule.run_pending()
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment