| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,6 +32,7 @@ | |||
| 32 | 32 | import os | |
| 33 | 33 | import os.path as osp | |
| 34 | 34 | from stat import S_ISLNK, ST_MODE | |
| 35 | + import socket | ||
| 35 | 36 | import subprocess | |
| 36 | 37 | import sys | |
| 37 | 38 | import tempfile | |
@@ -218,8 +219,15 @@ def git_daemon_launched(base_path, ip, port): | |||
| 218 | 219 | base_path=base_path, | |
| 219 | 220 | as_process=True, | |
| 220 | 221 | ) | |
| 221 | - # Yes, I know... fortunately, this is always going to work if sleep time is just large enough. | ||
| 222 | - time.sleep(1.0 if sys.platform == "win32" else 0.5) | ||
| 222 | + | ||
| 223 | + # Wait until git daemon listens for connections. | ||
| 224 | + for _attempt in range(1, 30): | ||
| 225 | + try: | ||
| 226 | + socket.create_connection((ip, port), timeout=30).close() | ||
| 227 | + break | ||
| 228 | + except ConnectionRefusedError: | ||
| 229 | + time.sleep(0.5) | ||
| 230 | + | ||
| 223 | 231 | except Exception as ex: | |
| 224 | 232 | msg = textwrap.dedent( | |
| 225 | 233 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments