Skip to content

RuntimeError: There is no current event loop in thread 'MainThread' with Python > 3.10 #18

@archcloudlabs

Description

@archcloudlabs

With Python versions >3.10, asynico needs to be first created with a new event loop as an argument.
Otherwise, you'll get a back trace like this:

Traceback (most recent call last):                                                                                                                                       
  File "/home/dllcoolj/run.py", line 17, in <module>                                                                                                                     
    client = CPGQLSClient(server_endpoint)                                                                                                                               
  File "/home/dllcoolj/venv/lib/python3.14/site-packages/cpgqls_client/client.py", line 34, in __init__                                                                  
    self._loop = asyncio.get_event_loop() if not event_loop else event_loop                                                                                              
                 ~~~~~~~~~~~~~~~~~~~~~~^^                                                                                                                                
  File "/usr/lib/python3.14/asyncio/events.py", line 715, in get_event_loop                                                                                              
    raise RuntimeError('There is no current event loop in thread %r.'                                                                                                    
                       % threading.current_thread().name)                                                                                                                
RuntimeError: There is no current event loop in thread 'MainThread'.                                                                                                     

This Stack Overflow post covers the details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions