Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. def on_contrbution_event(event):
  2. print(event)
  3. # and whatever
  4.  
  5. async def contribution_loop(event_filter, poll_interval):
  6. while True:
  7. for event in event_filter.get_new_entries():
  8. handle_event(event)
  9. await asyncio.sleep(poll_interval)
  10.  
  11. @app.task
  12. def contributions_events():
  13. logger.info("***** START CONTRIBUTION ******")
  14. w3 = get_w3_instance()
  15. contract_address = "0xaEC46A0f3869A7f4B856Bc53FC36f9bB3f0D77E6"
  16. lending_contract = get_lending_instance(w3, contract_address)
  17. event_filter = lending_contract.events.onContribution.createFilter(fromBlock="latest")
  18. loop = asyncio.get_event_loop()
  19. try:
  20. loop.run_until_complete(
  21. asyncio.gather(
  22. contribution_loop(event_filter, 2)))
  23. finally:
  24. loop.close()
  25. logger.info("***** END CONTRIBUTION ******")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement