import time
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://rinkeby.infura.io/v3/xxxxx')
#以下demo来自 web3.py官方[文档](https://web3py.readthedocs.io/en/latest/filters.html#examples-listening-for-events)
def handle_event(event):
print(event)
def log_loop(event_filter, poll_interval):
while True:
for event in event_filter.get_new_entries():
handle_event(event)
time.sleep(poll_interval)
def main():
block_filter = w3.eth.filter('latest')
log_loop(block_filter, 2)
if __name__ == '__main__':
main()
执行总是超时。有没有哪位同学知道如何解决这个问题? 谢谢~