qcc_kplugin.jobs ================ .. py:module:: qcc_kplugin.jobs .. autoapi-nested-parse:: Background ``qcc`` subprocesses for the GUI: run one command or a chain, show progress in the status bar, never block KLayout's UI thread and never open a modal dialog from the timer (errors go to the status bar and the log). ``run(steps, label, done)`` starts ``steps`` (a list of argument lists for ``qcc``) one after the other; ``done(ok, output)`` is called from the polling timer when the last step ended or one failed. QuCat on a large netlist can take minutes: the UI stays usable meanwhile, and the status bar shows the elapsed time. A job stops by itself: when a step fails (the rest are skipped, ``done(False, output)``), or after ``timeout`` seconds (the process is killed, ``timed_out`` is set and ``done(False, output)`` gets a "stopped" line). ``progress(job)``, when given, is called on every poll while the job runs (``live_text()`` is the output so far, also of the running step). Attributes ---------- .. autoapisummary:: qcc_kplugin.jobs.RUNNING Classes ------- .. autoapisummary:: qcc_kplugin.jobs.Job Functions --------- .. autoapisummary:: qcc_kplugin.jobs.busy qcc_kplugin.jobs.kill_tree qcc_kplugin.jobs.run Module Contents --------------- .. py:class:: Job(steps, label, done, cwd=None, timeout=None, progress=None) .. py:method:: cancel() -> None Stop the job: kill the ``qcc`` process (tree) of the running step, skip the rest, drop its log. ``done`` is called with ``(False, "cancelled")`` and ``job.cancelled`` set, so the caller can restore what it showed. .. py:method:: elapsed() -> float .. py:method:: live_text() -> str The output so far: the finished steps and what the running step has written. .. py:method:: poll() -> None .. py:method:: start() -> Job .. py:method:: wait(timeout: float = 600.0) -> bool Block until finished (tests only; the GUI never calls this). .. py:attribute:: cancelled :value: False .. py:attribute:: cwd :value: None .. py:attribute:: done .. py:attribute:: finished :value: False .. py:attribute:: index :value: -1 .. py:attribute:: label .. py:attribute:: log_path :type: pathlib.Path | None :value: None .. py:attribute:: ok :value: False .. py:attribute:: output :value: '' .. py:attribute:: proc :type: subprocess.Popen | None :value: None .. py:attribute:: progress :value: None .. py:attribute:: started .. py:attribute:: steps .. py:attribute:: timed_out :value: False .. py:attribute:: timeout :value: None .. py:attribute:: timer .. py:function:: busy(label_prefix: str) -> bool .. py:function:: kill_tree(proc: subprocess.Popen) -> None Stop a ``qcc`` process and its children (``qcc.exe`` is a launcher that starts python.exe). .. py:function:: run(steps, label, done, cwd=None, timeout=None, progress=None) -> Job .. py:data:: RUNNING :type: list[Job] :value: []