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

lib50 uses erroneous timeout value to get branches #82

Open
aenkya opened this issue Mar 4, 2025 · 0 comments
Open

lib50 uses erroneous timeout value to get branches #82

aenkya opened this issue Mar 4, 2025 · 0 comments

Comments

@aenkya
Copy link

aenkya commented Mar 4, 2025

I ran into this issue when attempting to run submit50 and I was getting

Connecting..........
Could not connect to GitHub, it seems you are offline.

Debug mode stack trace

Running this command in debug mode:
submit50 --log-level debug ai50/projects/2024/x/minesweeper
returns

Connecting...
Could not connect to GitHub, it seems you are offline.
Traceback (most recent call last):
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 802, in _get_branches
    output = child.read().strip().split("\r\n")
             ^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/pexpect/spawnbase.py", line 455, in read
    self.expect(self.delimiter)
  File "/Users/enkya/venv/lib/python3.11/site-packages/pexpect/spawnbase.py", line 354, in expect
    return self.expect_list(compiled_pattern_list,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/pexpect/spawnbase.py", line 383, in expect_list
    return exp.expect_loop(timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
           ^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/pexpect/expect.py", line 144, in timeout
    raise exc
pexpect.exceptions.TIMEOUT: Timeout exceeded.
<pexpect.pty_spawn.spawn object at 0x106068d90>
command: /opt/homebrew/bin/git
args: [b'/opt/homebrew/bin/git', b'ls-remote', b'--heads', b'https://github.com/ai50/projects']
buffer (last 100 chars): ''
before (last 100 chars): ''
after: <class 'pexpect.exceptions.TIMEOUT'>
match: None
match_index: None
exitstatus: None
flag_eof: False
pid: 17911
child_fd: 8
closed: False
timeout: 3
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: <lib50._api._StreamToLogger object at 0x104b43710>
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
    0: EOF

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 762, in __init__
    branches = self._get_branches()
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 807, in _get_branches
    raise TimeoutError(3)
lib50._errors.TimeoutError: 3

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/enkya/venv/bin/submit50", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/submit50/__main__.py", line 250, in main
    user_name, commit_hash, message = lib50.push("submit50", args.slug, CONFIG_LOADER, prompt=prompt)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 89, in push
    remote, (honesty, included, excluded) = connect(slug, config_loader, file_limit=DEFAULT_FILE_LIMIT)
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 357, in connect
    config_yaml = fetch_config(slug)
                  ^^^^^^^^^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 537, in fetch_config
    slug = Slug(slug)
           ^^^^^^^^^^
  File "/Users/enkya/venv/lib/python3.11/site-packages/lib50/_api.py", line 765, in __init__
    raise ConnectionError("Could not connect to GitHub, it seems you are offline.")
lib50._errors.ConnectionError: Could not connect to GitHub, it seems you are offline.
Submission cancelled.

Description

Upon review of this code, I notice the spawn call on the _get_branches method passes a timeout of 3 which is certainly not enough time for that command to resolve over the network. It seems to be a typo to me since the default timeout is 30.

Solution

Simply removing the passed timeout value so as to use the 30 second default value was enough to resolve my issue. If there is a need to conditionally change that timeout, It would be nice to update upstream files to enable explicit passing the timeout value required to the _get_branches method

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

1 participant