Skip to main content

lightweight event loop

Project description

sevent

The highest performance event loop.

Examples

Simple Http Client

import sevent

def on_data(s, data):
    print(data.decode("utf-8"))

s = sevent.tcp.Socket()
s.on_data(on_data)
s.on_close(lambda s: sevent.current().stop())
s.connect(('www.google.com', 80))
s.write(b'GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: Close\r\nUser-Agent: curl/7.58.0\r\nAccept: */*\r\n\r\n')

sevent.instance().start()
import sevent

async def http_test():
    s = sevent.tcp.Socket()
    await s.connectof(('www.google.com', 80))
    await s.send(b'GET / HTTP/1.1\r\nHost: www.google.com\r\nConnection: Close\r\nUser-Agent: curl/7.58.0\r\nAccept: */*\r\n\r\n')

    data = b''
    while True:
        try:
            data += (await s.recv()).read()
        except sevent.tcp.SocketClosed:
            break
    print(data.decode("utf-8"))
    await s.closeof()

sevent.run(http_test)

Simple TCP Port Forward

import sys
import sevent

def on_connection(server, conn):
    pconn = sevent.tcp.Socket()
    pconn.connect((sys.argv[2], int(sys.argv[3])))
    conn.link(pconn)

server = sevent.tcp.Server()
server.on_connection(on_connection)
server.listen(("0.0.0.0", int(sys.argv[1])))
sevent.instance().start()
import sys
import sevent

async def tcp_port_forward_server():
    server = sevent.tcp.Server()
    server.listen(("0.0.0.0", int(sys.argv[1])))

    while True:
        conn = await server.accept()
        pconn = sevent.tcp.Socket()
        pconn.connect((sys.argv[2], int(sys.argv[3])))
        conn.link(pconn)

sevent.run(tcp_port_forward_server)

License

sevent uses the MIT license, see LICENSE file for the details.

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

sevent-0.4.41.tar.gz (58.5 kB view details)

Uploaded Source

Built Distributions

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

sevent-0.4.41-cp314-cp314-win_amd64.whl (86.1 kB view details)

Uploaded CPython 3.14Windows x86-64

sevent-0.4.41-cp313-cp313-win_amd64.whl (86.3 kB view details)

Uploaded CPython 3.13Windows x86-64

sevent-0.4.41-cp312-cp312-win_amd64.whl (86.3 kB view details)

Uploaded CPython 3.12Windows x86-64

sevent-0.4.41-cp311-cp311-win_amd64.whl (86.0 kB view details)

Uploaded CPython 3.11Windows x86-64

sevent-0.4.41-cp310-cp310-win_amd64.whl (86.0 kB view details)

Uploaded CPython 3.10Windows x86-64

sevent-0.4.41-cp39-cp39-win_amd64.whl (86.3 kB view details)

Uploaded CPython 3.9Windows x86-64

sevent-0.4.41-cp38-cp38-win_amd64.whl (86.5 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

Details for the file sevent-0.4.41.tar.gz.

File metadata

  • Download URL: sevent-0.4.41.tar.gz
  • Upload date:
  • Size: 58.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41.tar.gz
Algorithm Hash digest
SHA256 01d7d998bcef8318d31a4de6a5e84b30944043550bf9318911a54b48a23ffb7b
MD5 468c33d1b60289e616a8e96e331d83fb
BLAKE2b-256 eb1c89c7b95402e633fe61ab79fdcd1e1f057b0182e991f2d384e3f10af640a8

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 86.1 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 13a8cd7e55ac2de34a64e53f8b69335b0cc85fb0acdacfc0c0422d684451d28b
MD5 161a850d134bf728c29ede6368c25636
BLAKE2b-256 520d72266df2c789e594a7ca96a4214c309a1bc876d9b9da807b4fa29cd61095

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2fd7e5d3573f7e26324ad82017e2bdc1f25bf55a286a1ea90c4b49f51cab2175
MD5 e17e99ce58c8e68126cb4777920ec57c
BLAKE2b-256 1a6c5c13e60076c2b175ca2d9bbd125ce36753965afd63aaa5ea93a394b67947

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 debf428befb22fac08ed1f5b8aefb82f797a14ed0620ff392940bdf50e0a9f9b
MD5 ee955f236830c65d31ac0f06ab265816
BLAKE2b-256 435f1d64c80a137cd12b3145e15fb483491d99cfbdfa789bbc6be67ec9191362

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 86.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1aaedb7d9c759024bba17168a19f126cbb011415446fea289e2c0d79e2d6457d
MD5 1c3b8c3a1b05ff1c8c3ae5604436bf3e
BLAKE2b-256 e472e7c1761d30f7cf868e2053c03f65f650e24502e98db779ea3f6829e83050

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 86.0 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 635ec4358298b5e50224bb57aa56885671b3c891912bf7f51af31fe92306d131
MD5 6c9c47a93e420956ff1ff15b57f2fef8
BLAKE2b-256 2d640f6f4c050abb373a575939d33e022b05ac5a3a5c34904dd69b9257d5c262

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ca9bdd6e85141b7be0ee8060191de3bd34fc29d5763260222222e3298f868c48
MD5 ba668a9b04e9c1778e91cdc97243c53c
BLAKE2b-256 eba75d8ece34aaa432c1b921825a44163e7be33f18ffcdd72ebcac45d5e68663

See more details on using hashes here.

File details

Details for the file sevent-0.4.41-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: sevent-0.4.41-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 86.5 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for sevent-0.4.41-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 3ed18465524d38447961bb409dce1fc377de07702914d434de1f5e4b86512a09
MD5 f0a7be737af74096217c777d82abac53
BLAKE2b-256 c3aa6bc2e857e6337a3d63d37fd1a543eb89387f1f2d987794b7f366a66d0e31

See more details on using hashes here.

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