Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- loop = asyncio.get_event_loop()
- class Some:
- def __init__(self):
- self.cache = []
- self.i = 0
- async def chota_run(self):
- while True:
- await asyncio.sleep(1)
- self.i += 1
- print('add to cache {}'.format(self.i))
- self.cache.append(self.i)
- print('cache: {}'.format(self.cache))
- async def clear_cache(self):
- while True:
- await asyncio.sleep(5)
- print('!!! clear cache !!!')
- self.cache = []
- if __name__ == '__main__':
- some = Some()
- loop.create_task(some.chota_run())
- loop.create_task(some.clear_cache())
- loop.run_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement