Skip to content

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

Open

Description

@Madnessiano

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?.

Activity

  1. BOT-TI commented on Jan 23, 2023

    @BOT-TI

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions