Advertisement
Guest User

html_parse

a guest
Aug 14th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def get_data(html):
  2.     ...
  3.  
  4.  
  5. async def reader():
  6.     sub = await aioredis.create_redis('redis://localhost')
  7.     ch = await sub.subscribe('chan:1')
  8.     with Pool(cpu_count()) as pool:
  9.         while (await ch[0].wait_message()):
  10.             data = await ch[0].get_json()
  11.             pool.apply_async(get_data, (data,))
  12.     await sub.unsubscribe('chan:1')
  13.     sub.close()
  14.  
  15.  
  16. if __name__ == '__main__':
  17.     asyncio.get_event_loop().run_until_complete(reader())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement