# eric6.Utilities.BackgroundService

Module implementing a background service for the various checkers and other python interpreter dependent functions.

### Global Attributes

None

### Classes

BackgroundService | Class implementing the main part of the background service.

### Functions

None

## BackgroundService

Class implementing the main part of the background service.

### Derived from

QTcpServer

### Class Attributes

None

### Class Methods

None

### Methods

BackgroundService | Constructor of the BackgroundService class.
__processQueue | Private method to take the next service request and send it to the client.
__receive | Private method to receive the response from the clients.
__send | Private method to send a job request to one of the clients.
__startExternalClient | Private method to start the background client as external process.
enqueueRequest | Public method implementing a queued processing of incomming events.
on_disconnectSocket | Private slot called when connection to a client is lost.
on_newConnection | Private slot for new incomming connections from the clients.
preferencesOrProjectChanged | Public slot to restart the built in languages.
restartService | Public method to restart a given lanuage.
serviceConnect | Public method to announce a new service to the background service/client.
serviceDisconnect | Public method to remove the service from the service list.
shutdown | Public method to cleanup the connections and processes when eric is shuting down.

### Static Methods

None

#### BackgroundService (Constructor)

BackgroundService()

Constructor of the BackgroundService class.

#### BackgroundService.__processQueue

__processQueue()

Private method to take the next service request and send it to the client.

#### BackgroundService.__receive

__receive(lang)

Private method to receive the response from the clients.

lang
  language of the incomming connection (str)

#### BackgroundService.__send

__send(fx, lang, fn, data)

Private method to send a job request to one of the clients.

fx
  remote function name to execute (str)
lang
  language to connect to (str)
fn
  filename for identification (str)
data
  function argument(s) (any basic datatype)

#### BackgroundService.__startExternalClient

__startExternalClient(interpreter, port)

Private method to start the background client as external process.

interpreter
  path and name of the executable to start (string)
port
  socket port to which the interpreter should connect (int)

Returns:
  the process object (QProcess or None)

#### BackgroundService.enqueueRequest

enqueueRequest(fx, lang, fn, data)

Public method implementing a queued processing of incomming events.

Dublicate service requests updates an older request to avoid overrun or starving of the services.

fx
  function name of the service (str)
lang
  language to connect to (str)
fn
  filename for identification (str)
data
  function argument(s) (any basic datatype(s))

#### BackgroundService.on_disconnectSocket

on_disconnectSocket(lang)

Private slot called when connection to a client is lost.

lang
  client language which connection is lost (str)

#### BackgroundService.on_newConnection

on_newConnection()

Private slot for new incomming connections from the clients.

#### BackgroundService.preferencesOrProjectChanged

preferencesOrProjectChanged()

Public slot to restart the built in languages.

#### BackgroundService.restartService

restartService(language, forceKill=False)

Public method to restart a given lanuage.

language
  to restart (str)
forceKill=
  flag to kill a running task (bool)

#### BackgroundService.serviceConnect

serviceConnect(fx, lang, modulepath, module, callback, onErrorCallback=None)

Public method to announce a new service to the background service/client.

fx
  function name of the service (str)
lang
  language of the new service (str)
modulepath
  full path to the module (str)
module
  name to import (str)
callback
  function on service response (function)
onErrorCallback
  function if client isn't available (function)

#### BackgroundService.serviceDisconnect

serviceDisconnect(fx, lang)

Public method to remove the service from the service list.

fx
  function name of the service (function)
lang
  language of the service (str)

#### BackgroundService.shutdown

shutdown()

Public method to cleanup the connections and processes when eric is shuting down.

Up