Skip to content

Commit

Permalink
Add connect to IPCMessageSubscriber's async_methods
Browse files Browse the repository at this point in the history
Fixes saltstack#60049 by making sure an IPCMessageSubscriber that is wrapped by
SyncWrapper has a connect method that runs the coroutine rather than
returns a fugure.
  • Loading branch information
dwoz authored and Ch3LL committed Jun 1, 2021
1 parent 40b5451 commit c996074
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions salt/transport/ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ class IPCMessageSubscriber(IPCClient):

async_methods = [
"read",
"connect",
]
close_methods = [
"close",
Expand Down
22 changes: 22 additions & 0 deletions tests/pytests/unit/transport/test_ipc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pytest
import salt.ext.tornado.iostream
import salt.transport.ipc
import salt.utils.asynchronous


def test_ipc_connect_in_async_methods():
"The connect method is in IPCMessageSubscriber's async_methods property"
assert "connect" in salt.transport.ipc.IPCMessageSubscriber.async_methods


def test_ipc_connect_sync_wrapped():
"""
Ensure IPCMessageSubscriber.connect gets wrapped by
salt.utils.asynchronous.SyncWrapper.
"""
puburi = "/tmp/noexist.ipc"
subscriber = salt.utils.asynchronous.SyncWrapper(
salt.transport.ipc.IPCMessageSubscriber, args=(puburi,), loop_kwarg="io_loop",
)
with pytest.raises(salt.ext.tornado.iostream.StreamClosedError):
subscriber.connect()

0 comments on commit c996074

Please sign in to comment.