Skip to content

Commit df4ae6f

Browse files
committed
fix(client): store user-provided event loop parameter
The loop parameter was accepted in __init__ but never assigned to self._event_loop when provided, silently ignoring the user's custom loop.
1 parent 52fccfa commit df4ae6f

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

kanboard.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def __init__(
9696
self._timeout = timeout
9797
self._ignore_hostname_verification = ignore_hostname_verification
9898

99-
if not loop:
99+
if loop:
100+
self._event_loop = loop
101+
else:
100102
try:
101103
self._event_loop = asyncio.get_event_loop()
102104
except RuntimeError:

tests/test_kanboard.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23+
import asyncio
2324
import types
2425
import unittest
2526
import warnings
@@ -112,6 +113,14 @@ def test_async_call_returns_result(self):
112113
result = loop.run_until_complete(self.client.my_method_async())
113114
self.assertEqual(42, result)
114115

116+
def test_custom_event_loop(self):
117+
custom_loop = asyncio.new_event_loop()
118+
try:
119+
client = kanboard.Client(self.url, "username", "password", loop=custom_loop)
120+
self.assertIs(client._event_loop, custom_loop)
121+
finally:
122+
custom_loop.close()
123+
115124
def test_custom_user_agent(self):
116125
client = kanboard.Client(self.url, "username", "password", user_agent="CustomAgent/1.0")
117126
body = b'{"jsonrpc": "2.0", "result": true, "id": 123}'

0 commit comments

Comments
 (0)