File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -345,10 +345,27 @@ def open(self) -> IO[bytes]:
345345 # Optional dependency:
346346 import fsspec
347347
348+ from aiohttp import ClientTimeout
349+
348350 # We need to call open() on the return value of fsspec.open() because
349351 # otherwise the filehandle will only be opened when used to enter a
350352 # context manager.
351- return cast (IO [bytes ], fsspec .open (self .url , mode = "rb" ).open ())
353+ #
354+ # Pass explicit timeouts to aiohttp to prevent indefinite hangs in
355+ # fsspec's sync() wrapper. Without these, a stalled connection to S3
356+ # (or minio in tests) causes fsspec's background IO thread to block
357+ # forever, which in turn blocks the calling thread in
358+ # threading.Event.wait() — see https://github.com/fsspec/filesystem_spec/issues/1666
359+ return cast (
360+ IO [bytes ],
361+ fsspec .open (
362+ self .url ,
363+ mode = "rb" ,
364+ client_kwargs = {
365+ "timeout" : ClientTimeout (total = 120 , sock_read = 60 , sock_connect = 30 )
366+ },
367+ ).open (),
368+ )
352369
353370 def get_size (self ) -> int :
354371 return self .size
Original file line number Diff line number Diff line change @@ -1145,6 +1145,7 @@ def test_nwb2asset(simple2_nwb: Path) -> None:
11451145 )
11461146
11471147
1148+ @pytest .mark .timeout (120 )
11481149@pytest .mark .xfail (reason = "https://github.com/dandi/dandi-cli/issues/1450" )
11491150def test_nwb2asset_remote_asset (nwb_dandiset : SampleDandiset ) -> None :
11501151 pytest .importorskip ("fsspec" )
You can’t perform that action at this time.
0 commit comments