# Python X2Go (Client) API Documentation (v0.6.1.4)

## x2go.printqueue module

`x2go.printing.X2GoPrintQueue` sets up a thread that listens for incoming print jobs.

For each incoming print job in an X2Go session’s spool directory an individual thread is started (`x2go.printqueue.X2GoPrintJob`) that handles the processing of the incoming print job.

class x2go.printqueue.X2GoPrintJob(**kwargs)

  Bases: `Thread`

  For each X2Go print job we create a sub-thread that let’s the print job be processed in the background.

  As a handler for this class the function `x2go_printjob_handler()` is used.

class x2go.printqueue.X2GoPrintQueue(profile_name='UNKNOWN', session_name='UNKNOWN', spool_dir=None, print_action=None, print_action_args={}, client_instance=None, printing_backend='FILE', logger=None, loglevel=56)

  Bases: `Thread`

  If X2Go printing is supported in a particular `x2go.session.X2GoSession` instance this class provides a sub-thread for handling incoming X2Go print jobs.

  active_jobs = {}
  job_history = []
  pause()

    Prevent acceptance of new incoming print jobs. The processing of print jobs that are currently still active will be completed, though.

  print_action = None
  resume()

    Resume operation of the X2Go print spooler and continue accepting new incoming print jobs.

  run()

    Start this `x2go.printing.X2GoPrintQueue` thread…

  set_print_action(print_action, **kwargs)

    Modify the print action of this `x2go.printing.X2GoPrintQueue` thread during runtime. The change of print action will be valid for the next incoming print job.

    As kwargs you can pass arguments for the print action class to be set. Refer to the class descriptions of `x2go.printactions.X2GoPrintActionDIALOG`, `x2go.printactions.X2GoPrintActionPDFVIEW`, `x2go.printactions.X2GoPrintActionPRINT`, etc.

    Parameters:

      - print_action (`str` or `class`) – new print action to be valid for incoming print jobs

      - kwargs (`dict`) – extra options for the specified print action

  spooldir = None
  stop_thread()

    Stops this `x2go.printing.X2GoPrintQueue` thread completely.

x2go.printqueue.x2go_printjob_handler(job_file=None, pdf_file=None, job_title=None, print_action=None, parent_thread=None, logger=None)

  This function is called as a handler function for each incoming X2Go print job represented by the class `x2go.printqueue.X2GoPrintJob`.

  The handler function will (re-)read the »printing« configuration file (if no explicit `print_action` is passed to this function…). It then will execute the `<print_action>.do_print()` command.

  Parameters:

    - job_file (`str`) – file name of this print job’s Job File (Default value = None)

    - pdf_file (`str`) – PDF file name as placed in to the X2Go spool directory (Default value = None)

    - job_title (`str`) – human readable print job title (Default value = None)

    - print_action (`X2GoPrintActionXXX` nstance) – an instance of either of the possible `X2GoPrintActionXXX` classes (Default value = None)

    - parent_thread (`obj`) – the `x2go.printing.X2GoPrintQueue` thread that actually created this handler’s `x2go.printqueue.X2GoPrintJob` instance (Default value = None)

    - logger (`obj`) – the `x2go.printing.X2GoPrintQueue`’s logging instance (Default value = None)