Skip to main content

Launch a WSGIApplication in a background thread with werkzeug.

Project description

⚙️ Server Thread

Tests codecov PyPI conda

Launch a WSGIApplication in a background thread with werkzeug.

This application was created for localtileserver and provides the basis for how it can launch an image tile server as a background thread for visualizing data in Jupyter notebooks.

While this may not be a widely applicable library, it is useful for a few Python packages I have created that require a background service.

🚀 Usage

Use the ServerThread with any WSGIApplication.

Start by creating a WSGIApplication (this can be a flask app or a simple app like below):

# Create some WSGI Application
from werkzeug import Request, Response

@Request.application
def app(request):
    return Response("howdy", 200)

Then launch the app with the ServerThread class:

import requests
from server_thread import ServerThread

# Launch app in a background thread
server = ServerThread(app)

# Perform requests against the server without blocking
requests.get(f"http://{server.host}:{server.port}/").raise_for_status()

⬇️ Installation

Get started with server-thread to create applications that require a WSGIApplication in the background.

🐍 Installing with conda

Conda makes managing server-thread's dependencies across platforms quite easy and this is the recommended method to install:

conda install -c conda-forge server-thread

🎡 Installing with pip

If you prefer pip, then you can install from PyPI: https://pypi-hypernode.com/project/server-thread/

pip install server-thread

💭 Feedback

Please share your thoughts and questions on the Discussions board. If you would like to report any bugs or make feature requests, please open an issue.

If filing a bug report, please share a scooby Report:

import server_thread
print(server_thread.Report())

Project details


Download files

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

Source Distribution

server-thread-0.1.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

server_thread-0.1.0-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file server-thread-0.1.0.tar.gz.

File metadata

  • Download URL: server-thread-0.1.0.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.12

File hashes

Hashes for server-thread-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b648b99f8523f7477010e4df54086603306e2709e77de9533b52c40e9eaa233
MD5 54e89ee3fefbd2168c2d47e400da5e6e
BLAKE2b-256 8fa84606f69048a7af242159e89fb8df524dbd1fd46ec17eeabca8398525c89d

See more details on using hashes here.

Provenance

File details

Details for the file server_thread-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for server_thread-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbb3984e54bc10a5129bfb2dbaddfac38db41375af86706da9ff09c9247a4560
MD5 f9fbf27dcc9d54cd0b6381c4df051e54
BLAKE2b-256 454c4eedd02201a9d1f1d8698493928492e3b456f66bc1c981d02b78e2f8f3b0

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page