Skip to content

Commit db399b1

Browse files
authored
Merge pull request #410 from OpenBioSim/backport_409
Backport fix from PR #409. [ci skip]
2 parents 61c12f5 + a1fc95c commit db399b1

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

doc/source/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ organisation on `GitHub <https://github.com/openbiosim/sire>`__.
2525

2626
* Fixed parsing of AMBER and GROMACS GLYCAM force field topologies.
2727

28+
* Fix hang in ``sire.load`` function when shared GROMACS topology path is missing.
29+
2830
`2025.4.0 <https://github.com/openbiosim/sire/compare/2025.3.0...2025.4.0>`__ - February 2026
2931
---------------------------------------------------------------------------------------------
3032

src/sire/_load.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,16 @@ def _get_gromacs_dir():
7777

7878
if not os.path.exists(gromacs_tbz2):
7979
try:
80+
import socket
8081
import urllib.request
8182

82-
urllib.request.urlretrieve(f"{tutorial_url}/gromacs.tar.bz2", gromacs_tbz2)
83-
except Exception:
84-
# we cannot download - just give up
83+
with urllib.request.urlopen(
84+
f"{tutorial_url}/gromacs.tar.bz2", timeout=5
85+
) as response:
86+
with open(gromacs_tbz2, "wb") as f:
87+
f.write(response.read())
88+
except (Exception, socket.timeout):
89+
# we cannot download - continue without GROMACS
8590
return None
8691

8792
if not os.path.exists(gromacs_tbz2):
@@ -443,7 +448,7 @@ def load(
443448
gromacs_path = _get_gromacs_dir()
444449

445450
m = {
446-
"GROMACS_PATH": _get_gromacs_dir(),
451+
"GROMACS_PATH": gromacs_path,
447452
"show_warnings": show_warnings,
448453
"parallel": parallel,
449454
"ignore_topology_frame": ignore_topology_frame,

0 commit comments

Comments
 (0)