navigate Logo

Getting Started

  • Quick Start Guide
  • Software Installation
  • I Want To…

User Guide

  • Supported Hardware
  • Supported File Formats
  • User Interface Walkthrough
  • Setting Up A Microscope
  • Acquiring Data
  • Case Studies

Development

  • Contributing Guidelines
  • Developer Install
  • Software Architecture
  • Feature Container
  • REST-API
  • Plugin Architecture

Troubleshooting & Known Issues

  • Troubleshooting
  • Known Issues

Plugins

  • navigate Plugin Template
  • navigate Confocal Projection
  • navigate at Scale
  • navigate Constant Velocity Acquisition
  • navigate MMCore
  • navigate ilastik Server
  • navigate Photoactivation

Reference

  • Implemented Microscopes
  • Software API
navigate
  • navigate.controller.thread_pool.SynchronizedThreadPool
  • View page source

navigate.controller.thread_pool.SynchronizedThreadPool

class navigate.controller.thread_pool.SynchronizedThreadPool

Bases: object

A custom thread pool with synchronization and control features.

This class provides a thread pool for managing threads associated with different resources. It allows registering resources, creating threads, wrapping thread tasks, removing threads, and other thread-related operations with explicit control and synchronization.

Note

  • This class provides explicit control over thread creation, removal,

and synchronization. - It allows managing threads associated with different resources efficiently. - The clear method moves threads to the toDeleteList for later deletion.

__init__()

Initialize the SynchronizedThreadPool.

Methods

__init__()

Initialize the SynchronizedThreadPool.

clear()

Clear all the threads in the pool.

createThread(resourceName, target[, args, ...])

Create a thread and add it to the waitlist of the resource.

getRunningThread(resourceName)

Get the running thread of the resource.

globaltrace(frame, event, arg)

Global trace function.

killThreadInList(resourceName, threadList)

Kill all the threads in the threadList.

localtrace(frame, event, arg)

Local trace function.

moveToDelete(resourceName, taskThread)

Move a thread to the toDeleteList.

registerResource(resourceName)

Register a resource to the pool.

removeThread(resourceName, taskThread)

Remove a thread from the waitlist of the resource.

threadTaskWrapping(resourceName, target, *)

Wrap the target function of the thread.

Attributes

resources

The resources of the thread pool.

toDeleteList

The toDeleteList of the thread pool.

clear()

Clear all the threads in the pool.

createThread(resourceName, target, args=(), kwargs={}, *, callback=None, cbArgs=(), cbKargs={})

Create a thread and add it to the waitlist of the resource.

Parameters:
  • resourceName (str) – The name of the resource.

  • target (callable) – The target function of the thread.

  • args (tuple, optional) – The arguments of the target function, by default ()

  • kwargs (dict, optional) – The keyword arguments of the target function, by default {}

  • callback (callable, optional) – The callback function of the thread, by default None

  • cbArgs (tuple, optional) – The arguments of the callback function, by default ()

  • cbKargs (dict, optional) – The keyword arguments of the callback function, by default {}

Returns:

The created thread.

Return type:

SelfLockThread

getRunningThread(resourceName)

Get the running thread of the resource.

Parameters:

resourceName (str) – The name of the resource.

Returns:

The running thread.

Return type:

SelfLockThread

globaltrace(frame, event, arg)

Global trace function.

Parameters:
  • frame (frame) – The frame of the thread.

  • event (str) – The event of the thread.

  • arg (any) – The argument of the thread.

Returns:

The local trace function if the event is “call”, otherwise None.

Return type:

callable

killThreadInList(resourceName, threadList)

Kill all the threads in the threadList.

Parameters:
  • resourceName (str) – The name of the resource.

  • threadList (dict) – The threadList to kill.

localtrace(frame, event, arg)

Local trace function.

Parameters:
  • frame (frame) – The frame of the thread.

  • event (str) – The event of the thread.

  • arg (any) – The argument of the thread.

Returns:

The local trace function if the event is “exception”, otherwise None.

Return type:

callable

moveToDelete(resourceName, taskThread)

Move a thread to the toDeleteList.

Parameters:
  • resourceName (str) – The name of the resource.

  • taskThread (SelfLockThread) – The thread to move.

registerResource(resourceName)

Register a resource to the pool.

Parameters:

resourceName (str) – The name of the resource.

removeThread(resourceName, taskThread)

Remove a thread from the waitlist of the resource.

Parameters:
  • resourceName (str) – The name of the resource.

  • taskThread (SelfLockThread) – The thread to remove.

Returns:

Whether the thread is removed.

Return type:

bool

threadTaskWrapping(resourceName, target, *, callback=None, cbArgs=(), cbKargs={})

Wrap the target function of the thread.

Parameters:
  • resourceName (str) – The name of the resource.

  • target (callable) – The target function of the thread.

  • callback (callable, optional) – The callback function of the thread, by default None

  • cbArgs (tuple, optional) – The arguments of the callback function, by default ()

  • cbKargs (dict, optional) – The keyword arguments of the callback function, by default {}

Returns:

The wrapped target function.

Return type:

callable

resources

The resources of the thread pool.

Type:

dict

toDeleteList

The toDeleteList of the thread pool.

Type:

dict


© Copyright 2025, Dean Lab, UT Southwestern Medical Center.