Skip to content

Commit 2c9570d

Browse files
committed
Add trigger examples
1 parent 6ce72d6 commit 2c9570d

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

trigger_aiohttp.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import pusher
2+
import pusher.aiohttp
3+
import asyncio
4+
5+
def main():
6+
client = pusher.Pusher.from_env(
7+
backend=pusher.aiohttp.AsyncIOBackend,
8+
timeout=50
9+
)
10+
print("before trigger")
11+
response = yield from client.trigger("hello", "world", dict(foo='bar'))
12+
print(response)
13+
14+
asyncio.get_event_loop().run_until_complete(main())

trigger_tornado.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pusher
2+
import pusher.tornado
3+
import tornado.ioloop
4+
5+
ioloop = tornado.ioloop.IOLoop.instance()
6+
7+
def show_response(response):
8+
print(response.result())
9+
ioloop.stop()
10+
11+
client = pusher.Pusher.from_env(
12+
backend=pusher.tornado.TornadoBackend,
13+
timeout=50
14+
)
15+
response = client.trigger("hello", "world", dict(foo='bar'))
16+
response.add_done_callback(show_response)
17+
print("Before start")
18+
ioloop.start()
19+
print("After start")

0 commit comments

Comments
 (0)