Worked around globals

This commit is contained in:
Teknique 2023-07-21 17:35:39 -07:00
parent 1e529c2474
commit c4620218aa

View File

@ -143,14 +143,12 @@ async def test_routing_context_app_call_loopback():
async def test_routing_context_app_message_loopback_big_packets(): async def test_routing_context_app_message_loopback_big_packets():
app_message_queue: asyncio.Queue = asyncio.Queue() app_message_queue: asyncio.Queue = asyncio.Queue()
global got_message count_hack = [0]
got_message = 0
async def app_message_queue_update_callback(update: veilid.VeilidUpdate): async def app_message_queue_update_callback(update: veilid.VeilidUpdate):
if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE: if update.kind == veilid.VeilidUpdateKind.APP_MESSAGE:
global got_message count_hack[0] += 1
got_message += 1 print(f"{count_hack[0]} ", end="")
sys.stdout.write("{} ".format(got_message))
await app_message_queue.put(update) await app_message_queue.put(update)
sent_messages: set[bytes] = set() sent_messages: set[bytes] = set()
@ -198,8 +196,7 @@ async def test_routing_context_app_message_loopback_big_packets():
@pytest.mark.asyncio @pytest.mark.asyncio
async def test_routing_context_app_call_loopback_big_packets(): async def test_routing_context_app_call_loopback_big_packets():
global got_message count_hack = [0]
got_message = 0
app_call_queue: asyncio.Queue = asyncio.Queue() app_call_queue: asyncio.Queue = asyncio.Queue()
@ -211,11 +208,8 @@ async def test_routing_context_app_call_loopback_big_packets():
while True: while True:
update = await app_call_queue.get() update = await app_call_queue.get()
global got_message count_hack[0] += 1
got_message += 1 print(f"{count_hack[0]} ", end="", flush=True)
sys.stdout.write("{} ".format(got_message))
sys.stdout.flush()
await api.app_call_reply(update.detail.call_id, update.detail.message) await api.app_call_reply(update.detail.call_id, update.detail.message)