← Back to team overview

mosquitto-users team mailing list archive

Re: python daemon - on_message callback not fired

 

Loop (any of the three options) is causing exception:

pi@raspberrypi ~/tmp $ ./Mosquitto.py start
Class initialization...
Creating an instance of MQ client...
Successfully created MQ client...
Subscribing to topics...
Failed to subscribe to topic "voice/all": (0, 1)
Failed to subscribe to topic "command/all": (0, 2)
Failed to subscribe to topic "voice/goof": (0, 3)
Failed to subscribe to topic "command/goof": (0, 4)
Failed to subscribe to topic "test": (0, 5)
Settings up callbacks...
Done setting up callbacks
Sending self-test message - you should see it soon after this message...
(0, 6)
Finished initialization...
Checking network loop...
0
Finished network loop...
pi@raspberrypi ~/tmp $ started with pid 28744
Traceback (most recent call last):
  File "./Mosquitto.py", line 72, in <module>
    daemon_runner.do_action()
  File
"/usr/local/lib/python2.7/dist-packages/python_daemon-1.6-py2.7.egg/daemon/runner.py",
line 189, in do_action
    func(self)
  File
"/usr/local/lib/python2.7/dist-packages/python_daemon-1.6-py2.7.egg/daemon/runner.py",
line 134, in _start
    self.app.run()
  File "./Mosquitto.py", line 54, in run
    Client.mc.loop_forever()
  File "/usr/local/lib/python2.7/dist-packages/mosquitto.py", line 1000, in
loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python2.7/dist-packages/mosquitto.py", line 664, in
loop
    socklist = select.select(rlist, wlist, [], timeout)
select.error: (9, 'Bad file descriptor')



Sasha Bolotnov
www.bolotnov.info



On Tue, Feb 5, 2013 at 3:00 AM, Roger Light <roger@xxxxxxxxxx> wrote:

> Dear Alexander,
>
> > My problem is that on_message will not get hit.
>
> You aren't calling the network processing loop anywhere so only
> outgoing communication will happen. You should use loop()
> periodically, loop_start() once to run the network loop in a thread in
> the background, or loop_forever() to call the network loop in a
> blocking call. I guess that the latter is what you want without
> knowing the details of the daemon module:
>
> def run():
>     print('Entering running state...')
>     Client.mc.loop_forever()
>
> Cheers,
>
> Roger
>

Follow ups

References