-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix trio future deprecation warnings (PR #805)
- Loading branch information
Showing
19 changed files
with
110 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,75 @@ | ||
# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2019 Scille SAS | ||
|
||
import trio | ||
|
||
|
||
class ThreadFSAccess: | ||
def __init__(self, portal, workspace_fs): | ||
def __init__(self, trio_token, workspace_fs): | ||
self.workspace_fs = workspace_fs | ||
self._portal = portal | ||
self._trio_token = trio_token | ||
|
||
def _run(self, fn, *args): | ||
return trio.from_thread.run(fn, *args, trio_token=self._trio_token) | ||
|
||
def _run_sync(self, fn, *args): | ||
return trio.from_thread.run_sync(fn, *args, trio_token=self._trio_token) | ||
|
||
# Rights check | ||
|
||
def check_read_rights(self, path): | ||
return self._portal.run_sync(self.workspace_fs.transactions.check_read_rights, path) | ||
return self._run_sync(self.workspace_fs.transactions.check_read_rights, path) | ||
|
||
def check_write_rights(self, path): | ||
return self._portal.run_sync(self.workspace_fs.transactions.check_write_rights, path) | ||
return self._run_sync(self.workspace_fs.transactions.check_write_rights, path) | ||
|
||
# Entry transactions | ||
|
||
def entry_info(self, path): | ||
return self._portal.run(self.workspace_fs.transactions.entry_info, path) | ||
return self._run(self.workspace_fs.transactions.entry_info, path) | ||
|
||
def entry_rename(self, source, destination, *, overwrite): | ||
return self._portal.run( | ||
return self._run( | ||
self.workspace_fs.transactions.entry_rename, source, destination, overwrite | ||
) | ||
|
||
# Folder transactions | ||
|
||
def folder_create(self, path): | ||
return self._portal.run(self.workspace_fs.transactions.folder_create, path) | ||
return self._run(self.workspace_fs.transactions.folder_create, path) | ||
|
||
def folder_delete(self, path): | ||
return self._portal.run(self.workspace_fs.transactions.folder_delete, path) | ||
return self._run(self.workspace_fs.transactions.folder_delete, path) | ||
|
||
# File transactions | ||
|
||
def file_create(self, path, *, open): | ||
return self._portal.run(self.workspace_fs.transactions.file_create, path, open) | ||
return self._run(self.workspace_fs.transactions.file_create, path, open) | ||
|
||
def file_open(self, path, *, mode): | ||
return self._portal.run(self.workspace_fs.transactions.file_open, path, mode) | ||
return self._run(self.workspace_fs.transactions.file_open, path, mode) | ||
|
||
def file_delete(self, path): | ||
return self._portal.run(self.workspace_fs.transactions.file_delete, path) | ||
return self._run(self.workspace_fs.transactions.file_delete, path) | ||
|
||
def file_resize(self, path, length): | ||
return self._portal.run(self.workspace_fs.transactions.file_resize, path, length) | ||
return self._run(self.workspace_fs.transactions.file_resize, path, length) | ||
|
||
# File descriptor transactions | ||
|
||
def fd_close(self, fh): | ||
return self._portal.run(self.workspace_fs.transactions.fd_close, fh) | ||
return self._run(self.workspace_fs.transactions.fd_close, fh) | ||
|
||
def fd_seek(self, fh, offset): | ||
return self._portal.run(self.workspace_fs.transactions.fd_seek, fh, offset) | ||
return self._run(self.workspace_fs.transactions.fd_seek, fh, offset) | ||
|
||
def fd_read(self, fh, size, offset): | ||
return self._portal.run(self.workspace_fs.transactions.fd_read, fh, size, offset) | ||
return self._run(self.workspace_fs.transactions.fd_read, fh, size, offset) | ||
|
||
def fd_write(self, fh, data, offset): | ||
return self._portal.run(self.workspace_fs.transactions.fd_write, fh, data, offset) | ||
return self._run(self.workspace_fs.transactions.fd_write, fh, data, offset) | ||
|
||
def fd_resize(self, fh, length): | ||
return self._portal.run(self.workspace_fs.transactions.fd_resize, fh, length) | ||
return self._run(self.workspace_fs.transactions.fd_resize, fh, length) | ||
|
||
def fd_flush(self, fh): | ||
return self._portal.run(self.workspace_fs.transactions.fd_flush, fh) | ||
return self._run(self.workspace_fs.transactions.fd_flush, fh) |
Oops, something went wrong.