0

I am trying to publish something in a infinite loop. But its not working. If I try the same code without the loop it seems to work fine.

while True:
    print 'XYZ'
    self.publish(str(gameId), [obj], [], {}, {'acknowledge': True})
    #self.publish(str(gameId), [obj])
    time.sleep(5)

The above code prints 'XYZ' infinitely but I am not able to receive the publish on my client. The below code works fine and I receive the obj publish sends:

self.publish(str(gameId), [obj])
self.publish(str(gameId), [obj])
self.publish(str(gameId), [obj])
Deepak Puthraya
  • 1,325
  • 2
  • 17
  • 28
  • 2
    Can you explain the way in which it isn't working? Do you get an error message? Invalid output? – BlackVegetable Dec 14 '15 at 15:13
  • @BlackVegetable No I do not get any error message. If I add say print 'XYZ' it seems to print it infinitely without issue. Its just that self.publish doesn't seem to work in case of infinite loop. – Deepak Puthraya Dec 14 '15 at 15:23
  • Could you add the argument `acknowledge=True` to your publish call? It should raise an error or something similar, instead of the default silent failure pattern. – BlackVegetable Dec 14 '15 at 15:26
  • @BlackVegetable is this what you meant? I did not get any errors – Deepak Puthraya Dec 14 '15 at 15:38
  • That might be one way to pass that argument. The typical way is `self.my_function(normal_argument1, normal_argument2, keyword_argument=value)` such as `self.publish(str(gameId), [obj], acknowledge=True)`. That's troubling if it didn't error out. :( – BlackVegetable Dec 14 '15 at 15:42
  • See the documentation here http://autobahn.ws/python/reference/autobahn.wamp.html#autobahn.wamp.interfaces.IPublisher.publish for the pattern to get a Future return value from the `publish` call if `acknowledge=True`. – BlackVegetable Dec 14 '15 at 15:45
  • @BlackVegetable I made this change to the code `print self.publish(str(gameId), [obj], acknowledge = True)` And it prints None – Deepak Puthraya Dec 14 '15 at 16:08
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97881/discussion-between-blackvegetable-and-karma). – BlackVegetable Dec 14 '15 at 16:09

0 Answers0