Allow a way for consumers of the MultiTail generator to stop the generator#6
Allow a way for consumers of the MultiTail generator to stop the generator#6foxdan wants to merge 1 commit intoderpston:masterfrom foxdan:stop_generator
Conversation
…rator. If there is no new data being pumped into the tailed files a consumer will block forever. This allows for a graceful shutdown after draining the files if the producer has been shut down.
|
I'm not very keen on this because changing some magic variable in order to stop a generator feels odd. Would it be better to simply stop reading from the generator? (using break to get out of the loop) Or perhaps repeatedly call .poll() until you decide you don't want any more content? Not keen but open to discussing it further. |
|
It won't be possible to always break out of the loop if reading from the generator. This happens when there are no new lines to be yielded by the MultiTail object. The other option is to re-implement the generator using poll and implementing some method to stop it in the consuming code, but it makes the generator in MultiTail redundant. |
|
Good point on the first one. The two interfaces (poll and generator) are provided because some uses aren't compatible with one or or the other, and it seems like the simplest thing to do would be to reimplement the generator in your application. Still not keen on fiddling around "behind" the generator in order to stop it, it feels too weird. |
If there is no new data being pumped into the tailed files a consumer will
block forever. This allows for a graceful shutdown after draining the files
if the producer has been shut down.