Skip to main content

Bringing WebSockets, Http/Https High Performance servers for PyPy3 and Python3

Project description

socketify.py

Logo

GitHub Clones PyPI Downloads Discord

Documentation   •   Discord   •   Issues   •   Examples

💡 Features

  • WebSocket with pub/sub support
  • Fast and reliable Http/Https
  • Support for Windows, Linux and macOS Silicon & x64
  • Support for PyPy3 and CPython
  • Dynamic URL Routing with Wildcard & Parameter support
  • Sync and Async Function Support
  • Really Simple API
  • Fast and Encrypted TLS 1.3 quicker than most alternative servers can do even unencrypted, cleartext messaging
  • Per-SNI HttpRouter Support
  • Proxy Protocol v2
  • Shared or Dedicated Compression Support
  • Max Backpressure, Max Timeout, Max Payload and Idle Timeout Support
  • Automatic Ping / Pong Support
  • Per Socket Data
  • Middlewares
  • Templates Support (examples with Mako and Jinja2)
  • ASGI Server
  • WSGI Server
  • Plugins/Extensions

:mag_right: Upcoming Features

  • In-Memory Cache Tools
  • Fetch like API powered by libuv
  • Async file IO powered by libuv
  • Full asyncio integration with libuv
  • SSGI Server spec and support
  • RSGI Server support
  • Full Http3 support
  • HPy integration to better support CPython, PyPy and GraalPython
  • Hot Reloading

We created and adapted the full C API from uNetworking/uWebSockets and will integrate libuv powered fetch and file IO, this same C API is used by Bun

Join Github Discussions or Discord for help and have a look at the development progress.

:zap: Benchmarks

Socketify WebFramework HTTP requests per second (Linux x64)

image

WSGI Server requests per second (Linux x64)

image

ASGI Server requests per second (Linux x64)

image

WebSocket messages per second (Linux x64)

image

Http tested with TFB tool plaintext benchmark
WebSocket tested with Bun.sh bench chat-client
Source code in TechEmPower and for websockets in bench

Machine OS: Debian GNU/Linux bookworm/sid x86_64 Kernel: 6.0.0-2-amd64 CPU: Intel i7-7700HQ (8) @ 3.800GHz Memory: 32066MiB

📦 Installation

For macOS x64 & Silicon, Linux x64, Windows

pip install socketify
#or specify PyPy3
pypy3 -m pip install socketify
#or in editable mode
pypy3 -m pip install -e socketify

Using install via requirements.txt

socketify
pip install -r ./requirements.txt 
#or specify PyPy3
pypy3 -m pip install -r ./requirements.txt 

If you are using linux or macOS, you may need to install libuv and zlib in your system

macOS

brew install libuv
brew install zlib

Linux (Ubuntu/Debian)

apt install libuv1 zlib1g

Linux (RHEL/OEL)

yum install cmake zlib-devel libuv-devel

🤔 Usage

Hello world app

from socketify import App

app = App()
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()

SSL version sample

from socketify import App, AppOptions

app = App(AppOptions(key_file_name="./misc/key.pem", cert_file_name="./misc/cert.pem", passphrase="1234"))
app.get("/", lambda res, req: res.end("Hello World socketify from Python!"))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % config.port))
app.run()

WebSockets

from socketify import App, OpCode, CompressOptions

def ws_open(ws):
    print('A WebSocket got connected!')
    ws.send("Hello World!", OpCode.TEXT)

def ws_message(ws, message, opcode):
    #Ok is false if backpressure was built up, wait for drain
    ok = ws.send(message, opcode)
    
app = App()    
app.ws("/*", {
    'compression': CompressOptions.SHARED_COMPRESSOR,
    'max_payload_length': 16 * 1024 * 1024,
    'idle_timeout': 12,
    'open': ws_open,
    'message': ws_message,
    'drain': lambda ws: print(f'WebSocket backpressure: {ws.get_buffered_amount()}'),
    'close': lambda ws, code, message: print('WebSocket closed'),
    'subscription': lambda ws, topic, subscriptions, subscriptions_before: print(f'subscribe/unsubscribe on topic {topic} {subscriptions} {subscriptions_before}'),
})
app.any("/", lambda res,req: res.end("Nothing to see here!'"))
app.listen(3000, lambda config: print("Listening on port http://localhost:%d now\n" % (config.port)))
app.run()

We have more than 20 examples click here for more

:hammer: Building from source

#clone and update submodules
git clone https://github.com/cirospaciari/socketify.py.git
cd ./socketify.py
git submodule update --init --recursive --remote
#you can use make linux, make macos or call Make.bat from Visual Studio Development Prompt to build
cd ./src/socketify/native/ && make linux && cd ../../../
#install local pip
pypy3 -m pip install .
#install in editable mode
pypy3 -m pip install -e .
#if you want to remove
pypy3 -m pip uninstall socketify

:briefcase: Commercially supported

I'm a Brazilian consulting & contracting company dealing with anything related with socketify.py and socketify.rb

Don't hesitate sending a mail if you are in need of advice, support, or having other business inquiries in mind. We'll figure out what's best for both parties.

Special thank's to uNetworking AB to develop uWebSockets, uSockets and allow us to bring this features and performance to Python and PyPy

:heart: Sponsors

If you like to see this project thrive, you can sponsor us on GitHub too. We need all the help we can get.

Thank you Otavio Augusto to be the first sponsor of this project!

:star: Stargazers

Stargazers repo roster for @cirospaciari/socketify.py

:wrench: Forkers

Forkers repo roster for @cirospaciari/socketify.py

:grey_question: uvloop

We don't use uvloop, because uvloop don't support Windows and PyPy3 at this moment, this can change in the future, but right now we want to implement our own libuv + asyncio solution, and a lot more.

:dizzy: CFFI vs Cython vs HPy

Cython performs really well on Python3 but really bad on PyPy3, CFFI are chosen for better support PyPy3 until we got our hands on a stable HPy integration.

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

delian_socketify-0.1.0.tar.gz (6.4 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

delian_socketify-0.1.0-cp313-cp313-win_amd64.whl (962.1 kB view details)

Uploaded CPython 3.13Windows x86-64

delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

delian_socketify-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

delian_socketify-0.1.0-cp311-cp311-win_amd64.whl (962.1 kB view details)

Uploaded CPython 3.11Windows x86-64

delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

delian_socketify-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

delian_socketify-0.1.0-cp39-cp39-win_amd64.whl (962.1 kB view details)

Uploaded CPython 3.9Windows x86-64

delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ ARM64

delian_socketify-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file delian_socketify-0.1.0.tar.gz.

File metadata

  • Download URL: delian_socketify-0.1.0.tar.gz
  • Upload date:
  • Size: 6.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for delian_socketify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d9be242ed80f779ba44a494f18c326f5002090d7e60eb3800b53253fb185e8e
MD5 3f30db3e02031a91c1073f719f0f78d5
BLAKE2b-256 849f52fafb7bb532f6c2963f4e647ffdf032653596e253eb0ba86ed285c254a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0.tar.gz:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 38b5574b87996506bd3e9f32b908007d9c8fa078d92af2a043983ecf28089bfa
MD5 4d18608e45ab18675b112c5d1382d931
BLAKE2b-256 503100751cecce8f543b6ce4ccccaab43f1d639ad1d03e7418848e9a1cebef35

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp313-cp313-win_amd64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b4faf7372392d0da32cf49c9c42e854c744e85fa050178778214ee9658e295d5
MD5 a8049a65fd38d5fa82e6b9604a2bf928
BLAKE2b-256 81ed3927cfbcfa3c9fcb8e364f131934735d7fcfbcaaa4fece5efd4d8eacf5ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 068d44d22c0255f60ff9eaa5ab6e811ebef10dd88f5b587bd6080cca0fd2125a
MD5 71077d49830c72071fb03122c87bde0c
BLAKE2b-256 1b170515c3f0e49f156f7b9e94dcb1d8a6b13d4680dd998beecfe4f55e894833

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2468146cce3499842ec8b2bbc9826b73564fb5689b156fe22eedbb08bf91e8d7
MD5 c1e9420f359a6c786395e99765bd834f
BLAKE2b-256 90ddb1d70b92d52c540a3afefb3c50998c71ca63669051915b57a9b04a7f9b81

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 44801e245c5c93f5e1c0def897cbf34b6ce1f7afd424c22f978f40b650546771
MD5 9558e91c4d51e74288881c253474cf62
BLAKE2b-256 4fabf1d65d1638b5a9c8e5291619ac4deeda300b61c783b90a7e94d240ca0000

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2a2e355b2c46ae641aae0c982b7f47d8fe0e49a30ebf09860577bdc1c34b41b5
MD5 98d576b87bb98dc2aed39dbedd566c39
BLAKE2b-256 750898f8137732eaa91801c506b3b9811786f0ec9d0c796aa1c2357c6e9fa05c

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 062ff4ae45c09c319a8c80e5fbc888765360bf4b6b077b16fd6283c0260c309a
MD5 e274806d690a6dc69018f3f3dbc33fa9
BLAKE2b-256 8b3b59e2c199ec4d846f316d189d2abda93c807f35857df20c9b5184d149e63a

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 52249226c6304d4e11cc6db0ca713f7d6e744dcb11569251197af55277138936
MD5 40b674fc7057020ce2a1cf9ae40cd0c3
BLAKE2b-256 d2cd69dce84cb7e84e475ea36b34828ed3e5ff7bbc8476e44746d184c59a7d4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7378c01c040d1505d675f736a7d521d1ceae7ecdfe04a9a433bd74d2ab15c350
MD5 b8faab5c88759e53184e2812531ffdd0
BLAKE2b-256 9ae692936b8d708312b9658d8823c13f48cd7d5566b18a3bfe5a49544ddc37ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp39-cp39-win_amd64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4275c8ddd4eb2a426ee7ca27683129d15ac257b5bd22bf3604c8c37ff9c550e6
MD5 ef32c12b765f985e6d8653fb351ff32f
BLAKE2b-256 47c137a86487088a645b606f769c9904f9b7747208e8b6ef2508890e3b0f5fb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f826f0398bc882acf88d4463cfe296758620306bda4a98b48b29efe6fe728b43
MD5 09f10df04417fe65d7f24be78efc8b28
BLAKE2b-256 20b8658a1c265a75870fa4c471ffa6c7905aa4f89ca44cbcbeb85efd55bd1400

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file delian_socketify-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for delian_socketify-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 14f6d7e9d0233485f455051765647c13c6d65f3203a7bf65172b9cd0333e0106
MD5 55bb95f6237cb00dcfba2f0cf824561f
BLAKE2b-256 a5826454c2dbe12491ce6dd4dc42d523773f30aad222ebe8303931a607064c63

See more details on using hashes here.

Provenance

The following attestation bundles were made for delian_socketify-0.1.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on Delian-Alliance-Industries/socketify.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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