Skip to content

Commit

Permalink
fix: Fix typo in execute_command method (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrochart committed Feb 27, 2023
1 parent d87f77a commit abe378a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/app_model/registries/_commands_reg.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def execute_command(
self,
id: str,
*args: Any,
execute_asychronously: bool = False,
execute_asynchronously: bool = False,
**kwargs: Any,
) -> Future:
"""Execute a registered command.
Expand All @@ -167,7 +167,7 @@ def execute_command(
ID of the command to execute
*args: Any
Positional arguments to pass to the command
execute_asychronously : bool
execute_asynchronously : bool
Whether to execute the command asynchronously in a thread,
by default `False`. Note that *regardless* of this setting,
the return value will implement the `Future` API (so it's necessary)
Expand All @@ -192,7 +192,7 @@ def execute_command(
except KeyError as e:
raise KeyError(f"Command {id!r} not registered") from e # pragma: no cover

if execute_asychronously:
if execute_asynchronously:
with ThreadPoolExecutor() as executor:
return executor.submit(cmd, *args, **kwargs)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_command_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def test_commands_registry() -> None:
with pytest.raises(ValueError, match="Command 'my.id' already registered"):
reg.register_command("my.id", lambda: 42, "My Title")

assert reg.execute_command("my.id", execute_asychronously=True).result() == 42
assert reg.execute_command("my.id", execute_asychronously=False).result() == 42
assert reg.execute_command("my.id", execute_asynchronously=True).result() == 42
assert reg.execute_command("my.id", execute_asynchronously=False).result() == 42

reg.register_command("my.id2", raise_exc, "My Title 2")
future_async = reg.execute_command("my.id2", execute_asychronously=True)
future_sync = reg.execute_command("my.id2", execute_asychronously=False)
future_async = reg.execute_command("my.id2", execute_asynchronously=True)
future_sync = reg.execute_command("my.id2", execute_asynchronously=False)

with pytest.raises(RuntimeError, match="boom"):
future_async.result()
Expand Down

0 comments on commit abe378a

Please sign in to comment.