Re: How do you deal with lengthy server tasks?

On 2/3/19 1:26 PM, Biz.122 via libsoup-list wrote:
I would like to stream some audio with soup server. How would you go
about something like that? Each browser request will launch the server
callback that does all processing, but I cannot stay in there looping
and sending data. This will block any other requests.

I looked around a bit and found this:

Look at the "SlowData / soup_add_timeout" example.
Is this how you would typically perform streaming tasks or large file
transfers, and not completely locking up your server callback?

Yeah, kinda. The libsoup tests are generally not great examples to
follow because they are often doing weird things so as to test specific
codepaths or to confirm that old bugs are still fixed.

That said, tests/streaming-test.c is probably a better example to follow
that tests/context-test.c. The example there is written to send each new
chunk of response data immediately after the previous chunk is sent (by
using the "wrote_chunk" signal on the message) but you could have the
callback be triggered by something external instead. It's fine if you
queue up data faster than it gets written to the network, and it's fine
if you "underflow" and don't write data fast enough; the I/O will just
pause until you write the next chunk.

There's an old bug about adding "streaming-style" APIs to SoupServer
( that would work like
soup_session_send(), but it has never been implemented.

-- Dan

Best Regards,

Sent with ProtonMail <> Secure Email.

libsoup-list mailing list
libsoup-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]