Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate continous event stream #23

Open
HR-KSSK opened this issue May 11, 2020 · 2 comments
Open

How to generate continous event stream #23

HR-KSSK opened this issue May 11, 2020 · 2 comments

Comments

@HR-KSSK
Copy link

HR-KSSK commented May 11, 2020

I am trying to generate a continous event stream with this library.

I get this to work by using an endpoint which has to be called by the client which looks like:

@app.route('/api/get/statusupdate')
def status_update():
    controller = TestController()
    while True:
        sse.publish(controller.get_status(), type='greeting')
        time.sleep(5)

I am configuring the plugin with this:

app.config["REDIS_URL"] = "redis://localhost"
app.register_blueprint(sse, url_prefix='/stream')

Now I can call /stream in the client to listen to events, but I need to call /api/get/statusupdate first which is a workaround. Is it possible to do this withiout calling /api/get/statusupdate and directly output some data on the event endpoint?

@prathmeshpatel
Copy link

@HR-KSSK Why not just have threads or a background scheduler that calls your method in your flask app periodically?

@nilskretschmer
Copy link

nilskretschmer commented Dec 19, 2020

@HR-KSSK Why not just have threads or a background scheduler that calls your method in your flask app periodically?

Thanks for your reply - that's exactly what I'm doing right now. I think the use-case of this library does not match with what I needed to achieve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants