Skip to content

Conversation

@malfet
Copy link
Collaborator

@malfet malfet commented Nov 7, 2025

Set a new event loop for asyncio in Python 3.14 and above.

Otherwise invoking ghstack crashes with

ERROR: Fatal exception
Traceback (most recent call last):
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/logs.py", line 105, in manager
    yield
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/cli.py", line 47, in cli_context
    yield shell, config, github
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/cli.py", line 281, in submit
    ghstack.submit.main(
    ~~~~~~~~~~~~~~~~~~~^
        msg=message,
        ^^^^^^^^^^^^
    ...<13 lines>...
        direct_opt=direct_opt,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/submit.py", line 259, in main
    submitter = Submitter(**kwargs)
  File "<string>", line 24, in __init__
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/submit.py", line 379, in __post_init__
    repo = ghstack.github_utils.get_github_repo_info(
        github=self.github,
    ...<4 lines>...
        remote_name=self.remote_name,
    )
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/github_utils.py", line 71, in get_github_repo_info
    name_with_owner = get_github_repo_name_with_owner(
        sh=sh,
        github_url=github_url,
        remote_name=remote_name,
    )
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/github_utils.py", line 28, in get_github_repo_name_with_owner
    remote_url = sh.git("remote", "get-url", remote_name)
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/shell.py", line 281, in git
    return self._maybe_rstrip(self.sh(*(("git",) + args), **kwargs))
                              ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/shell.py", line 200, in sh
    loop = asyncio.get_event_loop()
  File "/opt/homebrew/Cellar/[email protected]/3.14.0_1/Frameworks/Python.framework/Versions/3.14/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'.

Set a new event loop for asyncio in Python 3.14 and above.

Otherwise invoking `ghstack` crashes with
```
ERROR: Fatal exception
Traceback (most recent call last):
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/logs.py", line 105, in manager
    yield
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/cli.py", line 47, in cli_context
    yield shell, config, github
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/cli.py", line 281, in submit
    ghstack.submit.main(
    ~~~~~~~~~~~~~~~~~~~^
        msg=message,
        ^^^^^^^^^^^^
    ...<13 lines>...
        direct_opt=direct_opt,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/submit.py", line 259, in main
    submitter = Submitter(**kwargs)
  File "<string>", line 24, in __init__
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/submit.py", line 379, in __post_init__
    repo = ghstack.github_utils.get_github_repo_info(
        github=self.github,
    ...<4 lines>...
        remote_name=self.remote_name,
    )
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/github_utils.py", line 71, in get_github_repo_info
    name_with_owner = get_github_repo_name_with_owner(
        sh=sh,
        github_url=github_url,
        remote_name=remote_name,
    )
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/github_utils.py", line 28, in get_github_repo_name_with_owner
    remote_url = sh.git("remote", "get-url", remote_name)
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/shell.py", line 281, in git
    return self._maybe_rstrip(self.sh(*(("git",) + args), **kwargs))
                              ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nshulga/py3.14-local/lib/python3.14/site-packages/ghstack/shell.py", line 200, in sh
    loop = asyncio.get_event_loop()
  File "/opt/homebrew/Cellar/[email protected]/3.14.0_1/Frameworks/Python.framework/Versions/3.14/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'.
```
@ezyang
Copy link
Owner

ezyang commented Nov 7, 2025

Put it in main instead?

@malfet malfet requested a review from ezyang November 7, 2025 19:33
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

Successfully merging this pull request may close these issues.

3 participants