I am using twisted to distribute some information to several clients.
I have a consumer (implements IConsumer) with the write method overridden to write to all connected consumer clients.
I have a data source implemented as a generator.
Here is my main function
factory = TelemetryFactory()
one2many = ConsumerToManyClientConsumers()
# writes from the datalines generator to one2many
telem = TelemetryProducer(one2many, datalines)
factory.setSource(one2many)
reactor.listenTCP(1234, factory)
reactor.run()
How do I run the generator (or the TelemetryProducer) so that the it always runs no matter how many clients there are (0-10)?
Edit: Using reactor.callInThread(fn) seems to give the desired behaviour, except that CTRL+C doesn't properly exit the program. After CTRL+C, all connections are refused, but control is not yielded back to the shell.
fn? Please see sscce.org