Simple Event-Driven IO for Python
Project description
Thor
About Thor
Thor is yet another Python 3 library for evented IO.
There are many such libraries for Python already available. Thor focuses on making it easy to build high-performance HTTP intermediaries like proxies, load balancers, content transformation engines and service aggregators. Of course, you can use it just as a client or server too.
It aims to be as fast as possible, to implement the protocols correctly, and to be simple. You can help meet these goals by contributing issues, patches and tests.
Thor’s EventEmitter API is influenced by^H^H^H copied from NodeJS; if you’re familiar with Node, it shouldn’t be too hard to use Thor. However, Thor is nothing like Twisted; this is considered a feature.
Currently, Thor has an event loop as well as TCP, UDP and HTTP APIs (client and server). New APIs (e.g., DNS) and capabilities should be arriving soon, along with a framework for intermediation.
Requirements
Thor just requires a current version of Python.
Currently, it will run on most Posix platforms; specifically, those that offer one of poll,
epoll or kqueue.
Installation
Using pip:
pip install thor
On some operating systems, that might be pip3. Otherwise, download a tarball and install using:
python setup.py install
Using Thor
The documentation is a good starting point; see also the docstrings for the various modules, as well as the tests, to give an idea of how to use Thor.
For example, a very simple HTTP server looks like this:
import thor, thor.http
def test_handler(exch):
@thor.events.on(exch)
def request_start(*args):
exch.response_start(200, "OK", [('Content-Type', 'text/plain')])
exch.response_body('Hello, world!')
exch.response_done([])
if __name__ == "__main__":
demo_server = thor.http.HttpServer('127.0.0.1', 8000)
demo_server.on('exchange', test_handler)
thor.run()
Support and Contributions
See Thor's GitHub to give feedback, view and report issues, and contribute code.
All helpful input is welcome, particularly code contributions via a pull request (with test cases).
Why Thor?
Thor is not only “a hammer-wielding god associated with thunder, lightning, storms, oak trees, strength, destruction, fertility, healing, and the protection of mankind”, he’s also my Norwegian Forest Cat.
Thor (the software program) grew out of nbhttp, which itself came from earlier work on evented Python in redbot.
Thor (the cat) now rules our house with a firm but benevolent paw. He gets sick if we give him any milk, though.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file thor-0.12.5.tar.gz.
File metadata
- Download URL: thor-0.12.5.tar.gz
- Upload date:
- Size: 52.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88814d8ad8c7c9c037d587db339b5857d10f08ba9030bcdf37575258f8da1d60
|
|
| MD5 |
89a590d20a7583d0023119389c1ddf8a
|
|
| BLAKE2b-256 |
7c6112d360794a3fe0404e6b0485596c4881858b209317b2f39dffec3c9cf9f5
|
Provenance
The following attestation bundles were made for thor-0.12.5.tar.gz:
Publisher:
publish.yml on mnot/thor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thor-0.12.5.tar.gz -
Subject digest:
88814d8ad8c7c9c037d587db339b5857d10f08ba9030bcdf37575258f8da1d60 - Sigstore transparency entry: 780235144
- Sigstore integration time:
-
Permalink:
mnot/thor@c3cfde97a3a6ffba7142151640fd0ec6071260fa -
Branch / Tag:
refs/tags/v0.12.5 - Owner: https://github.com/mnot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c3cfde97a3a6ffba7142151640fd0ec6071260fa -
Trigger Event:
push
-
Statement type:
File details
Details for the file thor-0.12.5-py3-none-any.whl.
File metadata
- Download URL: thor-0.12.5-py3-none-any.whl
- Upload date:
- Size: 65.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f76c701bdc85c0d63c123d4c27169f766f39ca7e71a202ce267b2ee48956d73
|
|
| MD5 |
263bd4922ad2e25acc32c012d0255981
|
|
| BLAKE2b-256 |
6f70e0dc76467564a49a68e5111c37475167fba409e6dbd7dc62bc716a59978f
|
Provenance
The following attestation bundles were made for thor-0.12.5-py3-none-any.whl:
Publisher:
publish.yml on mnot/thor
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thor-0.12.5-py3-none-any.whl -
Subject digest:
0f76c701bdc85c0d63c123d4c27169f766f39ca7e71a202ce267b2ee48956d73 - Sigstore transparency entry: 780235152
- Sigstore integration time:
-
Permalink:
mnot/thor@c3cfde97a3a6ffba7142151640fd0ec6071260fa -
Branch / Tag:
refs/tags/v0.12.5 - Owner: https://github.com/mnot
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c3cfde97a3a6ffba7142151640fd0ec6071260fa -
Trigger Event:
push
-
Statement type: