Last active
April 17, 2018 09:03
-
-
Save funkyboy/5bcbfc0cc0d821ddf9b73d6e7d70d367 to your computer and use it in GitHub Desktop.
Ably Python test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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