@@ -0,0 +1,1517 @@
+#!/usr/bin/env python%0A# -*- coding: utf-8 -*-%0A%0Aimport asyncio%0Aimport json%0A%0A%0Afrom alignak_backend_client.client import Backend%0A%0Abackend = Backend('http://demo.alignak.net:6000')%0Abackend.login('admin', 'admin')%0A%0Aendpoints = %5B%0A    'host',%0A    'service',%0A    'user',%0A    'history'%0A%5D%0A%0A@asyncio.coroutine%0Adef event_handler(endpoint, stop=False):%0A    print('Running on endpoint %25s' %25 endpoint)%0A    params = %7B%0A        'projection': json.dumps(%7B'_id': 1%7D)%0A    %7D%0A    data = backend.get_all(endpoint, params=params)%0A    print(%22Collected data: (%25d) %25s%22 %25 (len(data%5B'_items'%5D), data%5B'_items'%5D))%0A%0A    # Close app%0A    # if stop:%0A    #     print('stopping the loop')%0A    #     loop.stop()%0A%0A%0A# if __name__ == '__main__':%0A    # loop = asyncio.get_event_loop()%0A    #%0A    #%0A    # try:%0A    #     for endpoint in endpoints:%0A    #         loop.call_soon(event_handler, loop, endpoint, loop)%0A    #         print('starting event loop')%0A    #         # loop.call_soon(functools.partial(event_handler, endpoint, loop, stop=True))%0A    #%0A    #         loop.run_forever()%0A    # finally:%0A    #     print('closing event loop')%0A    #     loop.close()%0A%0Aif __name__ == '__main__':%0A    my_event_loop = asyncio.get_event_loop()%0A    try:%0A        for endpoint in endpoints:%0A            print('task creation started')%0A            task_obj = my_event_loop.create_task(event_handler(endpoint))%0A            my_event_loop.run_until_complete(task_obj)%0A    finally:%0A        my_event_loop.close()%0A%0A    # print(%22The task's result was: %7B%7D%22.format(task_obj.result()))

Test asyncio