# eric7.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, retrieving the running threads and their name and state.

### Derived from

None

### 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.
getExecutedFrame | Public method to return the currently executed frame.
lockClient | Public method to acquire the lock for this client.
patchGreenlet | Public method to patch the 'greenlet' module.
patchPyThread | Public method to patch Python _thread module.
patchPyThreading | Public method to patch the Python threading module.
patchQThread | Public method to patch the QtCore module's QThread.
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

Return:
  identifier of the created thread

#### ThreadExtension.dumpThreadList

dumpThreadList()

Public method to send the list of threads.

#### ThreadExtension.getExecutedFrame

getExecutedFrame(frame)

Public method to return the currently executed frame.

frame (frame object)
  the current frame

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

Return Type:
  frame object

#### ThreadExtension.lockClient

lockClient(blocking=True)

Public method to acquire the lock for this client.

blocking (bool)
  flag to indicating a blocking lock

Return:
  flag indicating successful locking

Return Type:
  bool

#### ThreadExtension.patchGreenlet

patchGreenlet(module)

Public method to patch the 'greenlet' module.

module (module)
  reference to the imported module to be patched

Return:
  flag indicating that the module was processed

Return Type:
  bool

#### ThreadExtension.patchPyThread

patchPyThread(module)

Public method to patch Python _thread module.

module (module)
  reference to the imported module to be patched

#### ThreadExtension.patchPyThreading

patchPyThreading(module)

Public method to patch the Python threading module.

module (module)
  reference to the imported module to be patched

#### ThreadExtension.patchQThread

patchQThread(module)

Public method to patch the QtCore module's QThread.

module (module)
  reference to the imported module to be patched

#### 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