-
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.
Merge pull request #195 from unihd-cag/194-cleanup-cache-on-close-fai…
…lure Don't fail on workspace close when channel close fails
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from typing import Any | ||
|
||
from skillbridge import Workspace | ||
from skillbridge.client.channel import Channel | ||
from skillbridge.client.translator import DefaultTranslator | ||
from skillbridge.client.workspace import _open_workspaces | ||
|
||
|
||
class DummyChannel(Channel): | ||
def send(self, data: str) -> str: | ||
pass | ||
|
||
def flush(self) -> None: | ||
pass | ||
|
||
def try_repair(self) -> Any: | ||
pass | ||
|
||
def close(self): | ||
raise RuntimeError("no, i won't close") | ||
|
||
|
||
def test_a_crash_while_closing_still_clears_the_cache(): | ||
dummy_channel = DummyChannel(1) | ||
ws = Workspace(channel=dummy_channel, id_=123, translator=DefaultTranslator()) | ||
_open_workspaces[123] = ws | ||
|
||
ws.close() | ||
assert 123 not in _open_workspaces |