ebraminio / aiosseclient Goto Github PK
View Code? Open in Web Editor NEWAsynchronous Server Side Events (SSE) client for Python 3
License: MIT License
Asynchronous Server Side Events (SSE) client for Python 3
License: MIT License
I use this in https://github.com/dpriskorn/asseeibot and would like to fetch it from PIP if possible.
I am operating against the Firebase Realtime Database.
I have the following code
import threading
from time import sleep
url = "https://databaseurl/messages.json?auth=idtoken"
async def message_reader():
async for event in aiosseclient(url):
print(event.event)
print(event)
message_reader_thread = threading.Thread(target=asyncio.run, args=(message_reader(),))
message_reader_thread.start()
while True:
print("Still reading messages")
sleep(30)
This code works, but breaks in two cases that I can't understand how to handle. First is when the idtoken
is bad and response gets a 401
back. The While loop still runs, but there is no error or way to exit the for loop. The second is when idtoken
expires (they only last an hour) and an event "auth_revoked" is received. Again, there is no way to observe the error, and the for loop keeps going because it is still getting "keep-alive" events, even though it's not receiving data anymore.
I need some way to have the script fail and exit on 401
and I need a way to somehow refresh/restart it with a new idtoken
periodically (hourly in this case).
Thabks a lot for writing and sharing this โค
I just build a small script/bot using this and mediawikiapi.
I have a suggestion to expand he readme with a filtering example, woukd that be accepted?
There is a fork with that, upstream it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.