# eric6.DebugClients.Python.ThreadExtension

Module implementing an import hook patching thread modules to get debugged too.

### Global Attributes

_qtThreadNumber

### Classes

DummyThreadWrapper | Wrapper class for threading._DummyThread.
QRunnableWrapper | Wrapper class for *.QRunnable.
QThreadWrapper | Wrapper class for *.QThread.
ThreadExtension | Class implementing the thread support for the debugger.
ThreadWrapper | Wrapper class for threading.Thread.
TimerWrapper | Wrapper class for threading.(_)Timer.

### Functions

None

## DummyThreadWrapper

Wrapper class for threading._DummyThread.

### Derived from

module._DummyThread, ThreadWrapper

### Class Attributes

None

### Class Methods

None

### Methods

DummyThreadWrapper | Constructor

### Static Methods

None

#### DummyThreadWrapper (Constructor)

DummyThreadWrapper(*args, **kwargs)

Constructor

Up

## QRunnableWrapper

Wrapper class for *.QRunnable.

### Derived from

module.QRunnable

### Class Attributes

None

### Class Methods

None

### Methods

QRunnableWrapper | Constructor

### Static Methods

None

#### QRunnableWrapper (Constructor)

QRunnableWrapper(*args, **kwargs)

Constructor

Up

## QThreadWrapper

Wrapper class for *.QThread.

### Derived from

module.QThread

### Class Attributes

None

### Class Methods

None

### Methods

QThreadWrapper | Constructor

### Static Methods

None

#### QThreadWrapper (Constructor)

QThreadWrapper(*args, **kwargs)

Constructor

Up

## ThreadExtension

Class implementing the thread support for the debugger.

Provides methods for intercepting thread creation, retriving the running threads and their name and state.

### Derived from

object

### Class Attributes

None

### Class Methods

None

### Methods

ThreadExtension | Constructor
_bootstrap | Bootstrap for threading, which reports exceptions correctly.
_bootstrapQThread | Bootstrap for QThread, which reports exceptions correctly.
attachThread | Public method to setup a standard thread for DebugClient to debug.
dumpThreadList | Public method to send the list of threads.
find_module | Public method returning the module loader.
getExecutedFrame | Public method to return the currently executed frame.
load_module | Public method to load a module.
lockClient | Public method to acquire the lock for this client.
setCurrentThread | Public method to set the current thread.
threadTerminated | Public method called when a DebugThread has exited.
unlockClient | Public method to release the lock for this client.
updateThreadList | Public method to update the list of running threads.

### Static Methods

None

#### ThreadExtension (Constructor)

ThreadExtension()

Constructor

#### ThreadExtension._bootstrap

_bootstrap(run)

Bootstrap for threading, which reports exceptions correctly.

run (method pointer)
  the run method of threading.Thread

#### ThreadExtension._bootstrapQThread

_bootstrapQThread(run)

Bootstrap for QThread, which reports exceptions correctly.

run (method pointer)
  the run method of *.QThread

#### ThreadExtension.attachThread

attachThread(target=None, args=None, kwargs=None, mainThread=False)

Public method to setup a standard thread for DebugClient to debug.

If mainThread is True, then we are attaching to the already started mainthread of the app and the rest of the args are ignored.

target
  the start function of the target thread (i.e. the user code)
args
  arguments to pass to target
kwargs
  keyword arguments to pass to target
mainThread
  True, if we are attaching to the already started mainthread of the app

Returns:
  identifier of the created thread

#### ThreadExtension.dumpThreadList

dumpThreadList()

Public method to send the list of threads.

#### ThreadExtension.find_module

find_module(fullname, path=None)

Public method returning the module loader.

fullname (str)
  name of the module to be loaded
path (str)
  path to resolve the module name

Returns:
  module loader object

Return Type:
  object

#### ThreadExtension.getExecutedFrame

getExecutedFrame(frame)

Public method to return the currently executed frame.

frame (frame object)
  the current frame

Returns:
  the frame which is excecuted (without debugger frames)

Return Type:
  frame object

#### ThreadExtension.load_module

load_module(fullname)

Public method to load a module.

fullname (str)
  name of the module to be loaded

Returns:
  reference to the loaded module

Return Type:
  module

#### ThreadExtension.lockClient

lockClient(blocking=True)

Public method to acquire the lock for this client.

blocking (bool)
  flag to indicating a blocking lock

Returns:
  flag indicating successful locking

Return Type:
  bool

#### ThreadExtension.setCurrentThread

setCurrentThread(threadId)

Public method to set the current thread.

threadId (int)
  the id the current thread should be set to.

#### ThreadExtension.threadTerminated

threadTerminated(threadId)

Public method called when a DebugThread has exited.

threadId (int)
  id of the DebugThread that has exited

#### ThreadExtension.unlockClient

unlockClient()

Public method to release the lock for this client.

#### ThreadExtension.updateThreadList

updateThreadList()

Public method to update the list of running threads.

Up

## ThreadWrapper

Wrapper class for threading.Thread.

### Derived from

module.Thread

### Class Attributes

None

### Class Methods

None

### Methods

ThreadWrapper | Constructor

### Static Methods

None

#### ThreadWrapper (Constructor)

ThreadWrapper(*args, **kwargs)

Constructor

Up

## TimerWrapper

Wrapper class for threading.(_)Timer.

### Derived from

timer, ThreadWrapper

### Class Attributes

None

### Class Methods

None

### Methods

TimerWrapper | Constructor

### Static Methods

None

#### TimerWrapper (Constructor)

TimerWrapper(interval, function, *args, **kwargs)

Constructor

Up