Skip to content

Commit

Permalink
Merge pull request #258 from unihd-cag/fix-close-collision
Browse files Browse the repository at this point in the history
Fix internal close command collision
  • Loading branch information
TM90 authored Apr 11, 2024
2 parents 7884247 + e25fd17 commit f9136e4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion skillbridge/client/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def try_repair(self) -> Exception | str:

def close(self) -> None:
if self.connected:
self.socket.sendall(b' 5close')
self.socket.sendall(b' 5$close')
self.socket.close()
self.connected = False

Expand Down
11 changes: 0 additions & 11 deletions skillbridge/client/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ def __getattr__(self, item: Any) -> NoReturn:
current_workspace = _no_workspace


def _register_well_known_functions(ws: Workspace) -> None:
@ws.register
def db_check(d_cellview: Any) -> None:
"""
Checks the integrity of the database.
"""
_ = d_cellview


_unbound = Symbol('unbound')


Expand Down Expand Up @@ -201,8 +192,6 @@ def __init__(

self.user = FunctionCollection(channel, 'user', self._translator)

_register_well_known_functions(self)

def _prepare_default_translator(self) -> DefaultTranslator:
translator = DefaultTranslator()
types = [('Remote', RemoteObject), ('Table', RemoteTable), ('Vector', RemoteVector)]
Expand Down
2 changes: 1 addition & 1 deletion skillbridge/server/python_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def handle_one_request(self) -> bool:

logger.debug(f"received {len(command)} bytes")

if command.startswith(b'close'):
if command.startswith(b'$close'):
logger.debug(f"client {self.client_address} disconnected")
return False
logger.debug(f"got data {command[:1000].decode()}")
Expand Down
23 changes: 22 additions & 1 deletion tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from time import sleep
from warnings import warn

from pytest import fixture, raises, skip
from pytest import fixture, mark, raises, skip

from skillbridge import LazyList, RemoteObject, RemoteTable, SkillCode, Symbol, Var, Workspace

Expand Down Expand Up @@ -236,11 +236,32 @@ def test_run_script_blocks_when_requested(ws: Workspace) -> None:
assert ws['plus'](Var(variable), 1) == 43


@mark.skip
def test_form_vectors_have_dir(ws: Workspace) -> None:
form = ws.hi.get_current_form()
assert 'button_layout' in dir(form)


@mark.skip
def test_form_vectors_have_getattr(ws: Workspace) -> None:
form = ws.hi.get_current_form()
assert isinstance(form.button_layout, list)


def test_outstring(ws: Workspace) -> None:
outstring = ws['outstring']
get_outstring = ws['getOutstring']
close = ws['close']
fprintf = ws['fprintf']

s = outstring()
assert get_outstring(s) == "" # noqa: PLC1901

assert fprintf(s, "Hello ")
assert get_outstring(s) == "Hello "

assert fprintf(s, "World")
assert get_outstring(s) == "Hello World"

assert close(s)
assert get_outstring(s) is None

0 comments on commit f9136e4

Please sign in to comment.