Skip to content

Commit

Permalink
Address the last bunch of @touilleMan's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
vxgmichel committed Aug 2, 2021
1 parent 3a1f1ac commit c3302fc
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion parsec/core/gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from parsec.core.gui.new_version import CheckNewVersion
from parsec.core.gui.systray import systray_available, Systray
from parsec.core.gui.main_window import MainWindow
from parsec.core.gui.trio_thread import run_trio_job_scheduler
from parsec.core.gui.trio_jobs import run_trio_job_scheduler
except ImportError as exc:
raise ModuleNotFoundError(
"""PyQt forms haven't been generated.
Expand Down
4 changes: 2 additions & 2 deletions parsec/core/gui/central_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
FSWorkspaceNoWriteAccess,
FSWorkspaceInMaintenance,
)
from parsec.core.gui.trio_thread import QtToTrioJobScheduler
from parsec.core.gui.trio_jobs import QtToTrioJobScheduler
from parsec.core.gui.mount_widget import MountWidget
from parsec.core.gui.users_widget import UsersWidget
from parsec.core.gui.devices_widget import DevicesWidget
Expand All @@ -37,7 +37,7 @@
from parsec.core.gui.custom_widgets import Pixmap
from parsec.core.gui.custom_dialogs import show_error
from parsec.core.gui.ui.central_widget import Ui_CentralWidget
from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob


async def _do_get_organization_stats(core: LoggedCore) -> OrganizationStats:
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/claim_device_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
BackendNotAvailable,
)
from parsec.core.gui import validators
from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui.desktop import get_default_device
from parsec.core.gui.custom_dialogs import show_error, GreyedDialog, show_info
from parsec.core.gui.lang import translate as _
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/claim_user_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
BackendNotAvailable,
)
from parsec.core.gui import validators
from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui.desktop import get_default_device
from parsec.core.gui.custom_dialogs import show_error, GreyedDialog, show_info
from parsec.core.gui.lang import translate as _
Expand Down
4 changes: 2 additions & 2 deletions parsec/core/gui/create_org_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
)
from parsec.core.local_device import save_device_with_password

from parsec.core.gui.trio_thread import QtToTrioJob
from parsec.core.gui.trio_jobs import QtToTrioJob
from parsec.core.gui.custom_dialogs import GreyedDialog, show_error, show_info
from parsec.core.gui.trio_thread import JobResultError
from parsec.core.gui.trio_jobs import JobResultError
from parsec.core.gui.desktop import get_default_device
from parsec.core.gui.lang import translate as _
from parsec.core.gui import validators
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/devices_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from PyQt5.QtGui import QColor

from parsec.core.backend_connection import BackendNotAvailable, BackendConnectionError
from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui.greet_device_widget import GreetDeviceWidget
from parsec.core.gui.lang import translate as _
from parsec.core.gui.custom_widgets import ensure_string_size
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/file_history_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QWidget

from parsec.core.gui.trio_thread import QtToTrioJob
from parsec.core.gui.trio_jobs import QtToTrioJob
from parsec.core.gui.lang import translate as _, format_datetime
from parsec.core.gui.custom_dialogs import show_error, GreyedDialog
from parsec.core.gui.file_size import get_filesize
Expand Down
3 changes: 2 additions & 1 deletion parsec/core/gui/files_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
FSFileNotFoundError,
)

from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui import desktop
from parsec.core.gui.file_items import FileType, TYPE_DATA_INDEX, UUID_DATA_INDEX
from parsec.core.gui.custom_dialogs import (
Expand Down Expand Up @@ -918,6 +918,7 @@ def _on_folder_create_error(self, job):
show_error(self, _("TEXT_FILE_FOLDER_CREATE_ERROR_UNKNOWN"))

def _on_import_success(self, job):
assert self.import_job is job
assert self.loading_dialog
self.loading_dialog.hide()
self.loading_dialog.setParent(None)
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/greet_device_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from parsec.core.backend_connection import BackendNotAvailable, BackendConnectionError
from parsec.core.invite import InviteError, InvitePeerResetError, InviteAlreadyUsedError
from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui.custom_dialogs import show_error, GreyedDialog, show_info
from parsec.core.gui.lang import translate as _
from parsec.core.gui.qrcode_widget import generate_qr_code
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/greet_user_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from parsec.api.protocol import HumanHandle
from parsec.core.backend_connection import BackendNotAvailable
from parsec.core.invite import InviteError, InvitePeerResetError, InviteAlreadyUsedError
from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui.custom_dialogs import show_error, GreyedDialog, show_info
from parsec.core.gui import validators
from parsec.core.gui.lang import translate as _
Expand Down
4 changes: 2 additions & 2 deletions parsec/core/gui/instance_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
MountpointWinfspNotAvailable,
)

from parsec.core.gui.trio_thread import QtToTrioJob
from parsec.core.gui.trio_thread import QtToTrioJobScheduler, run_trio_job_scheduler
from parsec.core.gui.trio_jobs import QtToTrioJob
from parsec.core.gui.trio_jobs import QtToTrioJobScheduler, run_trio_job_scheduler
from parsec.core.gui.parsec_application import ParsecApp
from parsec.core.gui.custom_dialogs import show_error, show_info_link
from parsec.core.gui.lang import translate as _
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
BackendOrganizationFileLinkAddr,
)
from parsec.api.protocol import InvitationType
from parsec.core.gui.trio_thread import QtToTrioJobScheduler
from parsec.core.gui.trio_jobs import QtToTrioJobScheduler
from parsec.core.gui.lang import translate as _
from parsec.core.gui.instance_widget import InstanceWidget
from parsec.core.gui.parsec_application import ParsecApp
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/new_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from parsec.serde import BaseSchema, fields, JSONSerializer, SerdeError
from parsec.core.gui import desktop
from parsec.core.gui.lang import translate as _
from parsec.core.gui.trio_thread import QtToTrioJob
from parsec.core.gui.trio_jobs import QtToTrioJob
from parsec.core.gui.ui.new_version_dialog import Ui_NewVersionDialog
from parsec.core.gui.ui.new_version_info import Ui_NewVersionInfo
from parsec.core.gui.ui.new_version_available import Ui_NewVersionAvailable
Expand Down
6 changes: 4 additions & 2 deletions parsec/core/gui/timestamped_workspace_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import pendulum

from parsec.core.gui.trio_thread import QtToTrioJob
from parsec.core.gui.trio_jobs import QtToTrioJob
from parsec.core.gui.lang import get_qlocale, translate as _, format_datetime
from parsec.core.gui.custom_dialogs import show_error, GreyedDialog
from parsec.core.gui.ui.timestamped_workspace_widget import Ui_TimestampedWorkspaceWidget
Expand Down Expand Up @@ -79,7 +79,8 @@ def set_time_limits(self):
self.time_edit.clearMaximumTime()

def on_error(self, job):
if self.limits_job and self.limits_job.status != "cancelled":
assert self.limits_job is job
if self.limits_job.status != "cancelled":
show_error(
self,
_("TEXT_WORKSPACE_TIMESTAMPED_VERSION_RETRIEVAL_FAILED"),
Expand All @@ -89,6 +90,7 @@ def on_error(self, job):
self.dialog.reject()

def on_success(self, job):
assert self.limits_job is job
creation = self.limits_job.ret.in_timezone("local")
self.limits_job = None
self.creation_date = (creation.year, creation.month, creation.day)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion parsec/core/gui/users_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
BackendInvitationOnExistingMember,
)

from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob
from parsec.core.gui.custom_dialogs import show_error, show_info, ask_question, get_text_input
from parsec.core.gui.custom_widgets import ensure_string_size
from parsec.core.gui.flow_layout import FlowLayout
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/workspace_sharing_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from parsec.core.types import WorkspaceRole
from parsec.core.backend_connection import BackendNotAvailable

from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob

from parsec.core.gui.custom_dialogs import show_error, GreyedDialog
from parsec.core.gui.custom_widgets import Pixmap
Expand Down
2 changes: 1 addition & 1 deletion parsec/core/gui/workspaces_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
MountpointNoDriveAvailable,
)

from parsec.core.gui.trio_thread import JobResultError, QtToTrioJob, JobSchedulerNotAvailable
from parsec.core.gui.trio_jobs import JobResultError, QtToTrioJob, JobSchedulerNotAvailable
from parsec.core.gui import desktop
from parsec.core.gui.custom_dialogs import show_error, get_text_input, ask_question
from parsec.core.gui.flow_layout import FlowLayout
Expand Down
7 changes: 6 additions & 1 deletion parsec/core/mountpoint/manager.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Parsec Cloud (https://parsec.cloud) Copyright (c) AGPLv3 2016-2021 Scille SAS

from parsec.core.core_events import CoreEvent
import trio
import logging
import sys
Expand All @@ -14,6 +13,7 @@

from async_generator import asynccontextmanager

from parsec.core.core_events import CoreEvent
from parsec.core.types import FsPath, EntryID
from parsec.core.fs.workspacefs import WorkspaceFSTimestamped
from parsec.utils import TaskStatus, start_task, open_service_nursery
Expand Down Expand Up @@ -175,6 +175,11 @@ async def curried_runner(task_status: TaskStatus):
self._mountpoint_tasks[key] = task_status
self.event_bus.send(CoreEvent.MOUNTPOINT_STARTED, **event_kwargs)

# It is the reponsability of the runner context teardown to wait
# for cancellation. This is done to avoid adding an extra nursery
# into the winfsp runner, for simplicity. This could change in the
# future in which case we'll simmply add a `sleep_forever` below.

finally:
# Pop the mountpoint task if its ours
if self._mountpoint_tasks.get(key) == task_status:
Expand Down
4 changes: 2 additions & 2 deletions tests/core/gui/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from parsec.core.local_device import save_device_with_password
from parsec.core.gui.main_window import MainWindow
from parsec.core.gui.workspaces_widget import WorkspaceButton
from parsec.core.gui.trio_thread import QtToTrioJobScheduler
from parsec.core.gui.trio_jobs import QtToTrioJobScheduler
from parsec.core.gui.login_widget import LoginWidget, LoginPasswordInputWidget, LoginAccountsWidget
from parsec.core.gui.central_widget import CentralWidget
from parsec.core.gui.lang import switch_language
Expand Down Expand Up @@ -76,7 +76,7 @@ def timed_out():
return
if timed_out():
raise TimeoutError(timeout_msg)
await self.wait(10)
await trio.sleep(0.010)

@asynccontextmanager
async def wait_signals(self, signals, *, timeout=5000):
Expand Down
2 changes: 1 addition & 1 deletion tests/core/gui/test_workspaces_reencrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _assert_error():
# Unexpected error is logged
if error_type is Exception:
caplog.assert_occured(
"[exception] Uncatched error [parsec.core.gui.trio_thread]"
"[exception] Uncatched error [parsec.core.gui.trio_jobs]"
)


Expand Down

0 comments on commit c3302fc

Please sign in to comment.