-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix trio future deprecation warnings #805
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b559c68
Work around trio issue #1308
vxgmichel 9fb7f56
Replace run_sync_in_worker_thread with to_thread.run_sync
vxgmichel 5b18b9d
Goodbye TrioBlockingPoral~
vxgmichel e9b2382
Replace trio.open_cancel_scope with trio.CancelScope
vxgmichel d03d071
Replace event.clear() with trio.Event()
vxgmichel 3dfcf48
Update our warning policy in the tests
vxgmichel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May cay dé fous !!!! python-trio/trio#637 ^^