MetaModel¶
class MetaModel()
Bases: QObject
Abstract base class for models.
Public Methods¶
Abstract Methods¶
These methods must be implemented by subclasses.
(none)
Concrete Methods¶
- MetaModel.discard_generator(channel: int, key: str) None¶
Clear the run state for one (key, channel) once its worker thread has finished.
Formerly
reset_lock, which reset no lock - it clears thethread_runningflag, which is what allowsset_generator()to stage a new run for this key and channel, and drops the spent generator.The generator is explicitly closed before being dropped. A plugin that declares serial channel operations holds its own lock across the generator’s
yields, and that lock is released when the generator is exhausted or closed; relying on the reference count falling to zero to finalize it would make release depend on garbage-collection timing, and a stranded lock here is a silent hang rather than an error.close()is a harmless no-op on a generator that already ran to completion.The finished
Worker/WorkerThreadpair is also popped out ofself.workers/self.threadsand scheduled for deletion here, for the same reason: leaving them in the dicts kept every generator closure and the channel data it touched alive for the rest of the session, and madestop_workers/handle_kill_workerlog “Stopping worker for channel N” for runs that had finished hours earlier. Both areQObject``s created on (and never moved from) this thread, so ``deleteLater()is the correct way to release them rather than waiting on Python’s reference counting.
- MetaModel.emit_progress_update(progress: float, identifier: str) None¶
Emit the progress update signal
- MetaModel.emit_text_to_display(text: str, identifier: str) None¶
Relay a worker’s message to the status panel.
Workers run on their own thread and report an early stop this way rather than by raising it as an ERROR record, which QtHandler would turn into a modal dialog.
- MetaModel.run_generators(key: str) None¶
Start one worker thread per channel for which a generator has been staged under this key.
Serialization is not decided here. A plugin that declares
force_serial_channel_operations()now takes its own lock inside its generator (seeserialize_channels()), so this method no longer asks the plugin anything and no longer hands the worker a lock. It used to emitglobal_signalfor that answer and read it back offself.serial_opson the next statement, which worked only because every hop in that chain was a same-thread automatic connection Qt resolves as a direct call - oneQt.QueuedConnectionanywhere in it would have silently degraded the lock toNone, with no error and no log line.- Parameters:
key (str) – the plugin key whose staged generators should be run
- MetaModel.set_generator(generator: Generator[float, bool | None, None], channel: int, key: str, metaclass: str) None¶
Add generator and set it to be run by a QThread.
- MetaModel.stop_workers(key: str | None = None, channel: int | None = None, exiting: bool = False) None¶
Stop workers based on specified key and/or channel.
Private Methods¶
Abstract Methods¶
These methods must be implemented by subclasses.
- abstractmethod MetaModel._init() None¶
Perform additional initialization specific to the algorithm being implemented. Must be implemented by subclasses.
This function is called at the end of the class constructor to perform additional initialization specific to the algorithm being implemented. kwargs provided to the base class constructor are available as class attributes.