Skip to content
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

putGlyph no longer returns an optional error message #1022

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions src/fontra/core/fonthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ async def processWrites(self) -> None:
self._writingInProgressEvent.set()

async def _processWritesOneCycle(self) -> None:
writeFunc: Callable[
[], Awaitable[None]
] # inferencing with partial() goes wrong
while self._dataScheduledForWriting:
writeKey, (writeFunc, connection) = popFirstItem(
self._dataScheduledForWriting
)
reloadPattern = _writeKeyToPattern(writeKey)
logger.info(f"write {writeKey} to backend")
try:
errorMessage = await writeFunc()
await writeFunc()
except Exception as e:
logger.error("exception while writing data: %r", e)
traceback.print_exc()
Expand All @@ -132,25 +135,6 @@ async def _processWritesOneCycle(self) -> None:
else:
# No connection to inform, let's error
raise
else:
if errorMessage:
messageDetail = f"The edit has been reverted.\n\n{errorMessage}"
try:
await self.reloadData(reloadPattern)
except Exception as e:
messageDetail = (
f"{errorMessage}\n\n"
"The edit could not be reverted due to an additional error."
f"\n\n{e!r}"
)
if connection is not None:
await connection.proxy.messageFromServer(
"The data could not be saved.",
messageDetail,
)
else:
# This ideally can't happen
assert False, errorMessage
await asyncio.sleep(0)

@asynccontextmanager
Expand Down Expand Up @@ -360,7 +344,9 @@ async def _prepareRootObject(self, change):
async def _updateLocalData(
self, rootKeys, rootObject, sourceConnection, writeToBackEnd
) -> None:
writeFunc: Callable[[], Awaitable] # inferencing with partial() goes wrong
writeFunc: Callable[
[], Awaitable[None]
] # inferencing with partial() goes wrong
for rootKey in rootKeys + sorted(rootObject._assignedAttributeNames):
if rootKey == "glyphs":
glyphSet = rootObject.glyphs
Expand Down