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

## x2go.cleanup module

A recommended X2Go session clean up helper function.

x2go.cleanup.x2go_cleanup(e=None, threads=None)

  For every Python X2Go application you write, please make sure to capture the `KeyboardInterrupt` and the `SystemExit` exceptions and call this function if either of the exceptions occurs.

  Example:

      import x2go

      try:
          my_x2goclient = x2go.X2GoClient(...)

          [... your code ...]

          sys.exit(0)
      except (KeyboardInterrupt, SystemExit):
          x2go.x2go_cleanup()

  Parameters:

    - e (`exception`) – if `x2go_cleanup()` got called as you caught an exception in your code this can be the `Exception` that we will process at the end of the clean-up (or if clean-up failed or was not appropriate) (Default value = None)

    - threads (`list`) – a list of threads to clean up (Default value = None)