Using jupyter notebook causes RuntimeError: asyncio.run() cannot be called from a running event loop
              
              #9271
            
            
              
                Unanswered
              
          
                  
                    
                      tyePhDCandy
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 1 comment 1 reply
-
| 
         Could  It would either be that or one of these solutions: loop = asyncio.get_event_loop()
loop.run_until_complete(client.run(TOKEN))
loop.close() | 
  
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
fact and question
The code works when I call the
.pyfile usingpython test.pyon command line. It does not work when I executed the code inside the cell of jupyter notebook.How do i modify my code such that it would work in jupyter notebook?
Here's my code.
Here's my errors
My investigation
I know
RuntimeError: asyncio.run() cannot be called from a running event loopis resulted from the use of jupyter notebook executing the code.Referencing this webpage asyncio-run-cannot-be-called-from-a-running-event-loop-when-using-jupyter, I concluded:
The asyncio.run() documentation says:
jupyter (IPython ≥ 7.0) is already running an event loop:
This function cannot be called when another asyncio event loop is running in the same thread.
Beta Was this translation helpful? Give feedback.
All reactions