Skip to main content

A simple module for creating a background thread and returning a Future object

Project description

Creates a thread with Future attributes.

Based on (and actively uses) features from concurrent.futures module to easily start a function in a new background thread without the overhead of using a ThreadPoolExecutor, while still providing a Future style handle around said thread.

Usage:

import time
from future_thread import Future, DeferredFuture

def background():
    time.sleep(10)
    return True

fut = Future(background)
fut.result()  # will block until thread finished


fut = DeferredFuture(background)
# do some other stuff
fut.start()

For more info on the Future object see: https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for future-thread, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size future_thread-1.0-py2.py3-none-any.whl (3.5 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page