File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,8 @@ def __init__(
57
57
asynchronous = None ,
58
58
target_protocol = None ,
59
59
target_options = None ,
60
+ semaphore = None ,
61
+ max_concurrent_tasks = None ,
60
62
** kwargs ,
61
63
):
62
64
if asynchronous is None :
@@ -67,7 +69,7 @@ def __init__(
67
69
else :
68
70
self .sync_fs = fsspec .filesystem (target_protocol , ** target_options )
69
71
self .protocol = self .sync_fs .protocol
70
- self .semaphore = asyncio . Semaphore ( 1 ) if not asynchronous else None
72
+ self .semaphore = semaphore
71
73
self ._wrap_all_sync_methods ()
72
74
73
75
@property
Original file line number Diff line number Diff line change @@ -199,7 +199,9 @@ def test_open(tmpdir):
199
199
200
200
@pytest .mark .asyncio
201
201
async def test_semaphore_synchronous ():
202
- fs = AsyncFileSystemWrapper (LockedFileSystem (), asynchronous = False )
202
+ fs = AsyncFileSystemWrapper (
203
+ LockedFileSystem (), asynchronous = False , semaphore = asyncio .Semaphore (1 )
204
+ )
203
205
204
206
paths = [f"path_{ i } " for i in range (1 , 3 )]
205
207
results = await asyncio .gather (* (fs ._cat_file (path ) for path in paths ))
@@ -209,7 +211,7 @@ async def test_semaphore_synchronous():
209
211
210
212
@pytest .mark .asyncio
211
213
async def test_deadlock_when_asynchronous ():
212
- fs = AsyncFileSystemWrapper (LockedFileSystem (), asynchronous = True )
214
+ fs = AsyncFileSystemWrapper (LockedFileSystem (), asynchronous = False , semaphore = asyncio . Semaphore ( 3 ) )
213
215
paths = [f"path_{ i } " for i in range (1 , 3 )]
214
216
215
217
with pytest .raises (RuntimeError , match = "Concurrent requests!" ):
You can’t perform that action at this time.
0 commit comments