Какова цель @inlineCallbacks в коде автобана Python, основанном на витой?

Я вижу код @inlineCallbacks в примерах автобана все время. Пример ниже;

class Component(ApplicationSession):
   """
   An application component that publishes an event every second.
   """

   @inlineCallbacks
   def onJoin(self, details):
      print("session attached")
      counter = 0
      while True:
         print(".")
         self.publish('com.myapp.topic1', counter)
         counter += 1
         yield sleep(1)

if __name__ == '__main__':
   from autobahn.twisted.wamp import ApplicationRunner
   runner = ApplicationRunner("ws://127.0.0.1:8080/ws", "realm1")
   runner.run(Component)

Какова цель @inlineCallbacks?

0 ответов

Другие вопросы по тегам