Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def on_contrbution_event(event):
- print(event)
- # and whatever
- async def contribution_loop(event_filter, poll_interval):
- while True:
- for event in event_filter.get_new_entries():
- handle_event(event)
- await asyncio.sleep(poll_interval)
- @app.task
- def contributions_events():
- logger.info("***** START CONTRIBUTION ******")
- w3 = get_w3_instance()
- contract_address = "0xaEC46A0f3869A7f4B856Bc53FC36f9bB3f0D77E6"
- lending_contract = get_lending_instance(w3, contract_address)
- event_filter = lending_contract.events.onContribution.createFilter(fromBlock="latest")
- loop = asyncio.get_event_loop()
- try:
- loop.run_until_complete(
- asyncio.gather(
- contribution_loop(event_filter, 2)))
- finally:
- loop.close()
- logger.info("***** END CONTRIBUTION ******")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement