mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-04 09:44:14 +00:00
Keep connection open and lock to prevent duplicate requests (#213)
* Keep connection open and lock to prevent duplicate requests * option to not update children * tweaks * typing * tweaks * run tests in the same event loop * memorize model * Update kasa/protocol.py Co-authored-by: Teemu R. <tpr@iki.fi> * Update kasa/protocol.py Co-authored-by: Teemu R. <tpr@iki.fi> * Update kasa/protocol.py Co-authored-by: Teemu R. <tpr@iki.fi> * Update kasa/protocol.py Co-authored-by: Teemu R. <tpr@iki.fi> * dry * tweaks * warn when the event loop gets switched out from under us * raise on unable to connect multiple times * fix patch target * tweaks * isrot * reconnect test * prune * fix mocking * fix mocking * fix test under python 3.7 * fix test under python 3.7 * less patching * isort * use mocker to patch * disable on old python since mocking doesnt work * avoid disconnect/reconnect cycles * isort * Fix hue validation * Fix latitude_i/longitude_i units Co-authored-by: Teemu R. <tpr@iki.fi>
This commit is contained in:
@@ -78,16 +78,17 @@ def cli(host, debug):
|
||||
),
|
||||
]
|
||||
|
||||
protocol = TPLinkSmartHomeProtocol()
|
||||
|
||||
successes = []
|
||||
|
||||
for test_call in items:
|
||||
|
||||
async def _run_query():
|
||||
protocol = TPLinkSmartHomeProtocol(host)
|
||||
return await protocol.query({test_call.module: {test_call.method: None}})
|
||||
|
||||
try:
|
||||
click.echo(f"Testing {test_call}..", nl=False)
|
||||
info = asyncio.run(
|
||||
protocol.query(host, {test_call.module: {test_call.method: None}})
|
||||
)
|
||||
info = asyncio.run(_run_query())
|
||||
resp = info[test_call.module]
|
||||
except Exception as ex:
|
||||
click.echo(click.style(f"FAIL {ex}", fg="red"))
|
||||
@@ -107,8 +108,12 @@ def cli(host, debug):
|
||||
|
||||
final = default_to_regular(final)
|
||||
|
||||
async def _run_final_query():
|
||||
protocol = TPLinkSmartHomeProtocol(host)
|
||||
return await protocol.query(final_query)
|
||||
|
||||
try:
|
||||
final = asyncio.run(protocol.query(host, final_query))
|
||||
final = asyncio.run(_run_final_query())
|
||||
except Exception as ex:
|
||||
click.echo(
|
||||
click.style(
|
||||
|
Reference in New Issue
Block a user