Skip to content

Allow using coordinator and exporter programatically#1867

Open
alextercete wants to merge 2 commits into
labgrid-project:masterfrom
ARM-software:handle-sigterm-sigint
Open

Allow using coordinator and exporter programatically#1867
alextercete wants to merge 2 commits into
labgrid-project:masterfrom
ARM-software:handle-sigterm-sigint

Conversation

@alextercete
Copy link
Copy Markdown
Contributor

Description
We spin up a local coordinator and exporter for automated testing, and we want to be able to tell whether they're ready before running our tests. Also, we use port 0 with the coordinator to let the kernel allocate a free port, so we need to know which port was actually used. So now you can do:

labgrid-coordinator --listen 127.0.0.1:0

And it will print to stdout:

listening on 127.0.0.1:46269

We also fixed an issue when interrupting the coordinator/exporter (e.g. Ctrl+c):

^CINFO:root:Starting graceful shutdown...
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "path/to/labgrid/labgrid/remote/coordinator.py", line 1211, in <module>
    main()
  File "path/to/labgrid/labgrid/remote/coordinator.py", line 1204, in main
    loop.run_until_complete(serve(args.listen, cleanup))
  File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
    self._run_once()
  File "/usr/lib/python3.10/asyncio/base_events.py", line 1871, in _run_once
    event_list = self._selector.select(timeout)
  File "/usr/lib/python3.10/selectors.py", line 469, in select
    fd_event_list = self._selector.poll(timeout, max_ev)
KeyboardInterrupt

Checklist

  • PR has been tested

alextercete and others added 2 commits May 12, 2026 15:35
Print to stdout when the exporter and coordinator are ready. External
programs can detect this and the coordinator's listening port.

Signed-off-by: Alex Tercete <alex.tercete@arm.com>
Reviewed-by: Alex Tercete <alex.tercete@arm.com> # gatekeeper
Co-authored-by: Luke Hackwell <luke.hackwell@arm.com>
Signed-off-by: Alex Tercete <alex.tercete@arm.com>
Reviewed-by: Alex Tercete <alex.tercete@arm.com> # gatekeeper
Co-authored-by: Luke Hackwell <luke.hackwell@arm.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 0% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.0%. Comparing base (ec5ec29) to head (ef785b9).
⚠️ Report is 2 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/remote/exporter.py 0.0% 15 Missing ⚠️
labgrid/remote/coordinator.py 0.0% 11 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1867     +/-   ##
========================================
+ Coverage    45.8%   46.0%   +0.2%     
========================================
  Files         182     180      -2     
  Lines       14720   14462    -258     
========================================
- Hits         6743    6654     -89     
+ Misses       7977    7808    -169     
Flag Coverage Δ
3.10 46.0% <0.0%> (+0.2%) ⬆️
3.11 46.0% <0.0%> (+0.2%) ⬆️
3.12 46.0% <0.0%> (+0.2%) ⬆️
3.13 45.9% <0.0%> (+0.2%) ⬆️
3.14 45.9% <0.0%> (+0.2%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants