Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delay creation of runner object #457

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions apps/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,11 @@ async def send_next_ping(self):
packet = struct.pack(
'>bbI',
PacketType.SEQUENCE,
PACKET_FLAG_LAST
if self.current_packet_index == self.tx_packet_count - 1
else 0,
(
PACKET_FLAG_LAST
if self.current_packet_index == self.tx_packet_count - 1
else 0
),
self.current_packet_index,
) + bytes(self.tx_packet_size - 6)
logging.info(color(f'Sending packet {self.current_packet_index}', 'yellow'))
Expand Down Expand Up @@ -1232,6 +1234,7 @@ async def run(self):
'cyan',
)
)

await self.connected.wait()
logging.info(color('### Connected', 'cyan'))

Expand Down Expand Up @@ -1591,8 +1594,8 @@ def central(
mode_factory = create_mode_factory(ctx, 'gatt-client')
classic = ctx.obj['classic']

asyncio.run(
Central(
async def run_central():
await Central(
transport,
peripheral_address,
classic,
Expand All @@ -1604,7 +1607,8 @@ def central(
encrypt or authenticate,
ctx.obj['extended_data_length'],
).run()
)

asyncio.run(run_central())


@bench.command()
Expand All @@ -1615,15 +1619,16 @@ def peripheral(ctx, transport):
role_factory = create_role_factory(ctx, 'receiver')
mode_factory = create_mode_factory(ctx, 'gatt-server')

asyncio.run(
Peripheral(
async def run_peripheral():
await Peripheral(
transport,
ctx.obj['classic'],
ctx.obj['extended_data_length'],
role_factory,
mode_factory,
).run()
)

asyncio.run(run_peripheral())


def main():
Expand Down
Loading