git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: master: t5800-remote-helpers.sh hangs on test "pulling from remote remote"

From
Clemens Buchacher <drizzd@aon.at>
Date
Apr 21, 2012, 23:35 UTC
Message-ID
<20120421233521.GB20473@ecki>
In-Reply-To
<20120421201524.GA18419@padd.com>
Hi Pete,
Thanks for solving the mystery.
On Sat, Apr 21, 2012 at 04:15:24PM -0400, Pete Wyckoff wrote:
Show 12 quoted lines
> 
> Not sure yet what is the right way to fix this.  And I don't know
> if it's just git-remote-testgit that has the problem because it
> forks an importer, or if other remote helpers would be similarly
> affected.
> 
> The easiest fix is to invoke "python -u" in
> git-remote-testgit.py, or do
> 
>     sys.stdin = os.fdopen(sys.stdin.fileno(), 'r', 0)
> 
> But I'm not sure if this works on all systems.

Which part are you worried about? Maybe the patch below is more portable?

> We could also consider adding a handshake after "export", to give the
> helper time to get ready.

Not sure I understand. The helper is throwing away some input. It seems to me there is nothing one can do to prevent such brokeness.

It would be nice if the deadlock could be detected and if git would time out in such a case, instead of hanging forever. But rather long delays can also be the result of the remote helper legimitately waiting for data from a slow network.

Clemens ---

diff --git a/git-remote-testgit.py b/git-remote-testgit.py
index 616e772..bdd1116 100644
--- a/git-remote-testgit.py
+++ b/git-remote-testgit.py
@@ -135,6 +135,22 @@ def update_local_repo(repo):
     return repo
 
 
+def read_line_fd(fd):
+    """Read from fd until end of line or EOF, and no further.
+    """
+
+    line = ''
+
+    while True:
+        c = os.read(fd, 1)
+        if c == '':
+            break
+        line += c
+        if c == '\n':
+            break
+
+    return line
+
 def do_import(repo, args):
     """Exports a fast-import stream from testgit for git to import.
     """
@@ -149,7 +165,7 @@ def do_import(repo, args):
     refs = [ref]
 
     while True:
-        line = sys.stdin.readline()
+        line = read_line_fd(sys.stdin.fileno())
         if line == '\n':
             break
         if not line.startswith('import '):
@@ -211,9 +227,7 @@ def read_one_line(repo):
         time.sleep(int(sleepy))
         debug("Awake, to readline")
 
-    line = sys.stdin.readline()
-
-    cmdline = line
+    cmdline = read_line_fd(sys.stdin.fileno())
 
     if not cmdline:
         warn("Unexpected EOF")
-- 
1.7.10
Previous: Pete WyckoffNext: Pete Wyckoff
Message 17 of 26 in “master: t5800-remote-helpers.sh hangs on test "pulling from remote remote"”
  1. Stefano LattariniApr 14, 2012
  2. Clemens BuchacherApr 14, 2012
  3. Stefano LattariniApr 15, 2012
  4. Clemens BuchacherApr 15, 2012
  5. Stefano LattariniApr 15, 2012
  6. Clemens BuchacherApr 15, 2012
  7. Stefano LattariniApr 15, 2012
  8. Clemens BuchacherApr 15, 2012
  9. Stefano LattariniApr 15, 2012
  10. Clemens BuchacherApr 15, 2012
  11. Stefano LattariniApr 15, 2012
  12. Clemens BuchacherApr 15, 2012
  13. Sverre RabbelierApr 17, 2012
  14. Pete WyckoffApr 19, 2012
  15. Stefano LattariniApr 15, 2012
  16. Pete WyckoffApr 21, 2012
  17. Clemens BuchacherApr 21, 2012
  18. Pete WyckoffApr 22, 2012
  19. git-remote-testgit: fix race when spawning fast-importPete Wyckoff, Apr 21, 2012
  20. Clemens BuchacherApr 21, 2012
  21. Pete WyckoffApr 22, 2012
  22. Clemens BuchacherApr 22, 2012
  23. Junio C HamanoApr 22, 2012
  24. [PATCHv2] git-remote-testgit: fix race when spawning fast-importPete Wyckoff, Apr 22, 2012
  25. Junio C HamanoApr 23, 2012
  26. Pete WyckoffApr 23, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.