Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: There is no current event loop loop = asyncio.get_event_loop() #6

Open
Madnessiano opened this issue Feb 27, 2022 · 1 comment

Comments

@Madnessiano
Copy link

sniper.py:106: DeprecationWarning: There is no current event loop
sniper.py:109: DeprecationWarning: There is no current event loop
asyncio.gather(

Why is that?.

@BOT-TI
Copy link

BOT-TI commented Jan 23, 2023

Haha this is really old topic, but the message "There is no current event loop" means that the code is trying to use an event loop, but there is no event loop currently running or available.

You have to set the loop, as example like this:

def main():
    event_filter = contract.events.PairCreated.createFilter(fromBlock='latest')
    #block_filter = web3.eth.filter('latest')
    # tx_filter = web3.eth.filter('pending')
    loop = asyncio.new_event_loop()

    #This will set the loop
    asyncio.set_event_loop(loop)

    try:
        loop.run_until_complete(
            asyncio.gather(
                log_loop(event_filter,2 )))
                # log_loop(block_filter, 2),
                # log_loop(tx_filter, 2)))
    finally:
        # close loop to free up system resources
        loop.close()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants