sysid / sse-starlette

BSD 3-Clause "New" or "Revised" License
505 stars 36 forks source link

Is there any way to yield messages on demand? #32

Closed arseniiarsenii closed 2 years ago

arseniiarsenii commented 2 years ago

All examples feature a simple use case with frequent yields with asyncio.sleep() delay between them. Is there any way I can yield a message on demand?

My use case is to send sporadic messages which can be hours or seconds apart from each other, so spinning up an endless loop which would fetch messages every 100 ms would be a waste of resources. Is there any way I can avoid doing that?

Thank you for your work, awesome module.

sysid commented 2 years ago

@arseniiarsenii, interesting question. There is no reason not to have sporadic yields only as long as you make sure the connection does not die (heartbeats). From a sse-starlette perspective I do not see any limitations.