question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Asynchronous event dispatching to allow Flask to respond immediately

See original GitHub issue

Description

As per the Events API documentation, we should send a valid response in 3 seconds, when using this API I found it quite difficult to figure out how to achieve this when I tried to implement something which lasted longer than 3 seconds.

We are still trying to get it working in our bot, but it got somewhat messy and I feel like that it would be much nicer if it were in this library rather than having to make our own.

The way I’d see this being implemented is that the event emitter would run each handler in a background process by default (or maybe a way to opt-in to this behaviour?). I understand this might cause issues for bots which are already dependent on the current behaviour of the API though, but I would be curious to know your thoughts about whether this is something you’d like to include in some form.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements

  • I’ve read and understood the Contributing guidelines and have done my best effort to follow them.
  • I’ve read and agree to the Code of Conduct.
  • I’ve searched for any related issues and avoided creating a duplicate issue.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:37 (20 by maintainers)

github_iconTop GitHub Comments

13reactions
aoberoicommented, Dec 14, 2018

As of now, there’s no active development on this issue. We’ve been thinking about doing some sample code to try and show developers how they might do asynchronous event dispatch in their application.

It would be useful to know if this interests you (please 👍 this comment). Also, there are many reactive frameworks we could use, but we can’t build a sample for all of them (examples mentioned above are gevent, responder, python-rq, twisted, etc). It would be really helpful to let us know if there are one or many of those that you are interested in.

3reactions
Roachcommented, Oct 15, 2018

We got another Python dev on the team (Welcome, @RodneyU215 🎉), so we should be picking this back up soon.

Thanks a ton for all of your input, guys. it’s been super helpful!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make a Python asyncio call from a Flask route - Stack Overflow
When a request comes into an async view, Flask will start an event loop in a thread, run the view function there, then...
Read more >
Using async and await — Flask Documentation (2.2.x)
When a request comes in to an async view, Flask will start an event loop in a thread, run the view function there,...
Read more >
Server-sent events in Flask without extra dependencies
Server-sent events in Flask without extra dependencies ... Server-sent events (SSE) is a mechanism for sending updates from a server to a client....
Read more >
Why isn't Flask async - YouTube
Slides to accompany this talk are available ...
Read more >
Request and Response cycle in Flask | Build modern APIs
It's really important to understand how flask takes the request and give the response back and what happens between these stages?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found