Skip to content

Commit f511ed2

Browse files
authored
bugfix: prevent RuntimeError from catching NotImplementedError (#1280)
* prevent RuntimeError from catching NotImplementedError * add test for bad multiple syncs
1 parent 9a1e624 commit f511ed2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

fsspec/asyn.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ def sync(loop, func, *args, timeout=None, **kwargs):
8383
loop0 = asyncio.events.get_running_loop()
8484
if loop0 is loop:
8585
raise NotImplementedError("Calling sync() from within a running loop")
86+
except NotImplementedError:
87+
raise
8688
except RuntimeError:
8789
pass
8890
coro = func(*args, **kwargs)

fsspec/tests/test_async.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ async def _dummy_async_func(self):
5353
await asyncio.sleep(1)
5454
return True
5555

56+
async def _bad_multiple_sync(self):
57+
fsspec.asyn.sync_wrapper(_DummyAsyncKlass._dummy_async_func)(self)
58+
return True
59+
5660
dummy_func = fsspec.asyn.sync_wrapper(_dummy_async_func)
61+
bad_multiple_sync_func = fsspec.asyn.sync_wrapper(_bad_multiple_sync)
5762

5863

5964
def test_sync_wrapper_timeout_on_less_than_expected_wait_time_not_finish_function():
@@ -77,6 +82,12 @@ def test_sync_wrapper_treat_timeout_0_as_none():
7782
assert test_obj.dummy_func(timeout=0)
7883

7984

85+
def test_sync_wrapper_bad_multiple_sync():
86+
test_obj = _DummyAsyncKlass()
87+
with pytest.raises(NotImplementedError):
88+
test_obj.bad_multiple_sync_func(timeout=5)
89+
90+
8091
def test_run_coros_in_chunks(monkeypatch):
8192
total_running = 0
8293

0 commit comments

Comments
 (0)