Repository navigation
multimer: python -c is a batch entry; the timing ledger's follow-ups - #106
Merged
Merged
Conversation
On CPython, interactive() treated any __main__ without __file__ as a bare prompt, which includes python -c. So a timer armed at the top of a -c one-liner chose the ambient strategy, App.run() returned at once and the process exited, where -m and a script file keep the app running. Consult batch() as the MicroPython branch already does, and let _cmdline_tokens fall back to sys.orig_argv where there is no /proc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On CPython,
python -c "..."that arms a timer before starting an app exits at once instead of running it._hostloop.interactive()took any__main__without__file__for a bare prompt, and a-cone-liner has no__file__either. The strategy came outambient,App.run()returned immediately, and the process ended.-mand a script file were fine.This consults
batch()in the CPython branch, as the MicroPython branch already did, so-cgets the samenonestrategy as-m._cmdline_tokens()also falls back tosys.orig_argvwhere there is no/proc(macOS), so the check works there too.Found while proving the android-runner launcher on 0.6.1 (PyDevices/android-runner#24). Arming a timer at the top of
python -c "...; import boot"made the launcher window open and the process exit in 0.2 s:boot returned ambient, exit status 0 after 0.2 s, the timer never firedSMOKE_TIMER none, and the launcher runs untiltimeoutstops it (status 124)Tests: two new cases in
tests/test_hostloop.py.test_cpython_dash_c_is_not_interactivefails onmainand passes here.test_hostloop.py(20) andtest_multimer*.py(36) pass withSDL_VIDEODRIVER=dummy.A second commit updates the ledger (
docs/timing-design.md,docs/timing-hardware-tests.md). The browser follow-ups pass: PyScript/Pyodide, and the rebuiltmp-wasmin PyDevices/PyDevices.github.io#9 and PyDevices/workbench#1. The runner'sMULTIMER_BACKENDline goes in PyDevices/android-runner#24. The phone visual pass is still owed.