← Back to team overview

mosquitto-users team mailing list archive

Re: Looping - collect backlog?

 

Hi Roy,

You shouldn't lose any messages. If you're just subscribing then as
soon as data is available for reading from the socket then thread
started in loop_start() will read it. If there is no incoming data
then the loop will pause for up to 1 second in the call to select().

By the way - you should move to using the Paho Python client. It is
the future version of mosquitto.py and the same, apart from the name
space.

Cheers,

Roger

On Tue, Jan 28, 2014 at 7:30 AM, Roy Barkas <roy@xxxxxxxx> wrote:
> Python client question:
>
> Assuming that all messages on my system are sent with QOS=0,
>
> If I use loop_start() rather than calling loop(0) repeatedly from a while
> loop, is there likely to be any difference in the number of messages that a
> subscribed client receives?  It looks to me like loop_start blocks for a
> second between retrieval of messages.
>
> I can afford to lose a message or two here and there but I need to be able
> to be comfortable that most messages will be delivered.
>
> I've chosen to use QOS 0 since I wanted to minimize the load and message
> volume on the broker and if I lose 1 or 2 messages out of a thousand I can
> tolerate that.  But if I'm at risk of losing 200 out of a thousand that's a
> worry...
> i.e.
>
> examples:
> while True:
>     client.loop(0)
>     time.sleep(0.001)
>
> vs:
>
> client.loop_start()
>
>
> --
> Mailing list: https://launchpad.net/~mosquitto-users
> Post to     : mosquitto-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~mosquitto-users
> More help   : https://help.launchpad.net/ListHelp
>


References