-
Notifications
You must be signed in to change notification settings - Fork 35
chore(TTk): split mainloop in ttk_init and ttk_run #491
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
base: main
Are you sure you want to change the base?
Conversation
I don't see why this should be required. It ought to be made such as in PR #469 so that it is enough to...
Otherwise, the excessive choice of different method calls make the module too confusing. |
|
This is because I don't want to initialize the signals and the drivers in the init, I already told you this. |
|
I agree that of course a solution cannot be done in a hacky way. There is no rush to implement this into the core, since I have a working patch for my use case in the time being, so there is no limit of time for you to consider the best way of going about this. As such, I think it is worth having a deeper consideration on the best approach to take before committing.
I do recall you telling me this, but I fail to understand the reason why this would be a bad thing to do? Are you thinking that this could this lead to an unstable state or something like that?
Why not? And if it cannot be during TTk initializing, then can perhaps another opportunity to do so be scheduled to trigger at the appropriate time, i.e. without the caller having to use an auxiliary ttk_init() method? |
|
One example could be something like this, # Any TTk() could be a different app provided by an external library or series of plugins
apps = {
'app' : TTk(),
'test' : TTk(),
'config' : TTk() }
mode = input()
apps.get(mode, TTk()).mainloop()Or in general any tool that require the control of the stdin/out/err before the mainloop, Normally the base instance of any major library don't initialise the drivers until the main routine is executed. |
|
I see. Thank you for taking the time for explaining this. It helps me to better understand use cases other than my own which are important to get right for correct operation in all runtime scenarios, and from thinking about your example it is clear that my proposal would cause such an implementation to be impossible. May I suggest then that the signals and drivers initialization routine be set in the main (or only) thread as a pending callback method in something like a Queue() or SimpleQueue() to be triggered upon entering the mainloop(). |
|
This sounds interesting but I am not sure about the implementation. |
|
In that example, a SimpleQueue() is used to drive the application's main event emitter (10 times per second), but here it needed only once to dispatch queued event callbacks at startup. |
|
I mean, how can I ensure that the queued callbacks run in the main thread if the mainloop is called on a separate thread? |
|
Put the end of the However, the start of the mainloop would also have to wait until the initialization has actually been completed (it cannot begin |
|
you mean using asyncio? |
|
I have no example for you, and upon further consideration I fear that such a mechanism is overly complicated and would be prone to failures or incompatibilities. Afterall, it would be satisfactory enough to call an init method before run, as you propose herein. |
No description provided.