L i_RddlZddlZddlZddlZddlmZmZddZGddeZy)N)AsyncFileSystem running_asynccFtjfd}|S)a Wraps a synchronous function to make it awaitable. Parameters ---------- func : callable The synchronous function to wrap. obj : object, optional The instance to bind the function to, if applicable. semaphore : asyncio.Semaphore, optional A semaphore to limit concurrent calls. Returns ------- coroutine An awaitable version of the function. cKr=4d{tjg|i|d{cdddd{Stjg|i|d{S7W787*#1d{7swY9xYw7wN)asyncio to_thread)argskwargsfunc semaphores i/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/fsspec/implementations/asyn_wrapper.pywrapperzasync_wrapper..wrappers   F F$..tEdEfEE F F F&&t=d=f=== FE F F F F=s] BA$BA*A&A* BA(!BA? B&A*(B*A<0A3 1A<8B) functoolswraps)r objr rs` ` r async_wrapperr s'&__T>> Nc^eZdZdZdZdZ dfd ZedZdZ e dZ xZ S) AsyncFileSystemWrapperaX A wrapper class to convert a synchronous filesystem into an asynchronous one. This class takes an existing synchronous filesystem implementation and wraps all its methods to provide an asynchronous interface. Parameters ---------- sync_fs : AbstractFileSystem The synchronous filesystem instance to wrap. ) asyncwrapperrFc | t}t|dd|i||||_nt j |fi||_|jj |_||_|jy)N asynchronous) rsuper__init__sync_fsfsspec filesystemprotocolr _wrap_all_sync_methods) selffsrtarget_protocoltarget_optionsr max_concurrent_tasksr __class__s rrzAsyncFileSystemWrapper.__init__6sn  (?L =l=f= >DL!,,_OODL -- " ##%rc4d|jjS)Nasync_)rfsid)r"s rr*zAsyncFileSystemWrapper.fsidKs ))*++rcdh}t|jD]}|jds||vrtj|j|}t |t rJt|j|}t|sltj|rt|||j}t|d||y)zg Wrap all synchronous methods of the underlying filesystem with asynchronous versions. open_)rr N) dirr startswithinspectgetattr_static isinstancepropertygetattrcallableiscoroutinefunctionrr setattr)r"excluded_methods method_nameattrmethod async_methods rr!z-AsyncFileSystemWrapper._wrap_all_sync_methodsOs#8t||, ?K%%c*k=M.M))$,, DD$)T\\;7F(C(CF(K,VX +/> ?rcLGfdd|}djd|_|S)a Create a new class that can be used to instantiate an AsyncFileSystemWrapper with lazy instantiation of the underlying synchronous filesystem. Parameters ---------- sync_fs_class : type The class of the synchronous filesystem to wrap. Returns ------- type A new class that wraps the provided synchronous filesystem class. c"eZdZfdZxZS)JAsyncFileSystemWrapper.wrap_class..GeneratedAsyncFileSystemWrapperc4|i|}t||yr)rr)r"r r rr' sync_fs_classs rrzSAsyncFileSystemWrapper.wrap_class..GeneratedAsyncFileSystemWrapper.__init__ss'88 )r)__name__ __module__ __qualname__r __classcell__)r'rAs@rGeneratedAsyncFileSystemWrapperr?rs  * *rrFAsyncWrapper)rB)clsrArFs ` r wrap_classz!AsyncFileSystemWrapper.wrap_classas4" *c * M**+7 3 (0/.r)NNNNNN) rBrCrD__doc__r cachablerr3r*r! classmethodrJrE)r's@rrr&sZ /HH !&*,,?$//rr)NN) rrr0r fsspec.asynrrrrrrrrOs' 6:T/_T/r