circus-tent/circus — pull request #840 by k4nar (2014-10-10 18:43:47+00:00)
Title: Add start callback

This 'cb' argument corresponds to a callback which will be called after the watchers have been started, if no loop has been provided.

It is called 'cb' and not 'callback' as otherwise it would conflict with the 'callback' argument accepted by every coroutines. Note that we can't use this argument here as arbiter.start will not return until the end, so the callback would never be called.

This is really helpful for projects using Circus as a library and not wanting to use a custom loop, as it allows them to call a coroutine inside the loop after everything has been initialized.

Providing a custom loop for Circus can be very hard, as you have to rewrite a lot of code to handle the shutdown properly. For example you have to write your own sighandlers. With this argument, most projects don't need to use their own loop.

It doesn't change anything for projects not using Circus as a library or using their own loop.

Note that I didn't add a test as it's nearly impossible to add one. In the tests we provide a custom loop so the callback will not be called.