-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[Python] Fix threading model #20234
[Python] Fix threading model #20234
Conversation
This fixes a number of issues with the Python REPL's threading model, namely: - Multiple, duplicated methods for stack initialization. - Stack initialization split across really odd places - Incorrect thread initialization - Incorrect order of initialization
Tagging SVE, given there are PRs that are dependent on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add back StackInit.cpp to contain at least Platform::MemoryInit.
We should not funnel everything through 'controller' (i.e. it should not go to controller/python) since for a full python package it makes sense to isolate things. There are things python could do without needing a controller. Things like 'parse qr codes' or (arguably hard due to very strong coupling today) dnssd operations.
only. Updated ChipStack to now use native to implicitly achieve this auto init (which sets up MemoryInit) before continuining onwards with controller-style initialization.
63798be
to
fa7ac2f
Compare
PR #20234: Size comparison from 1807fb1 to fa7ac2f Increases (2 builds for cyw30739, telink)
Decreases (1 build for telink)
Full report (16 builds for cyw30739, k32w, linux, mbed, nrfconnect, p6, telink)
|
PR #20234: Size comparison from 7514699 to ab27923 Increases (4 builds for cc13x2_26x2, telink)
Decreases (3 builds for cc13x2_26x2, esp32)
Full report (30 builds for cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
|
9619bf2
to
e6a7b2b
Compare
PR #20234: Size comparison from 4f7d5cf to e6a7b2b Increases (6 builds for cc13x2_26x2, cyw30739, efr32, esp32, mbed, telink)
Decreases (2 builds for cc13x2_26x2, telink)
Full report (41 builds for cc13x2_26x2, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, p6, telink)
|
* Fix Python Threading Model This fixes a number of issues with the Python REPL's threading model, namely: - Multiple, duplicated methods for stack initialization. - Stack initialization split across really odd places - Incorrect thread initialization - Incorrect order of initialization * Review feedback * Brought back the auto-stack init in native, albeit, a minimal version only. Updated ChipStack to now use native to implicitly achieve this auto init (which sets up MemoryInit) before continuining onwards with controller-style initialization. * Fix build
* Fix Python Threading Model This fixes a number of issues with the Python REPL's threading model, namely: - Multiple, duplicated methods for stack initialization. - Stack initialization split across really odd places - Incorrect thread initialization - Incorrect order of initialization * Review feedback * Brought back the auto-stack init in native, albeit, a minimal version only. Updated ChipStack to now use native to implicitly achieve this auto init (which sets up MemoryInit) before continuining onwards with controller-style initialization. * Fix build Co-authored-by: Jerry Johns <[email protected]>
Make sure to initialize logging after the native code init. This makes sure that the C++ pychip_native_init is called after pychip_CommonStackInit. This is required to make sure that the platform specific initialization in src/platform/Linux/PlatformManagerImpl.cpp is being called before using the SDK. See also: project-chip/connectedhomeip#20234
Problem
Fixes the threading issues identified in #20233.
Solution
GetLibraryHandle
.StackInit.cpp
, and consolidated all stack initialization logic in a single place:pychip_DeviceController_StackInit
. This now correctly orchestrates memory initialization, platform init, controller factory initialization and finally, starting up the Matter thread.PlatformMgr().StartEventLoopTask()
to start up the Matter thread.pychip_DeviceController_StackShutdown
to now actually be the symmetric mirror of init, AND, co-locate that next to Init to make it easy to read.Tests
Ran the patch in #20178 and ensured it passed.