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.38.tar.gz (56.8 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.38-cp313-cp313-win_amd64.whl (84.9 kB view details)

Uploaded CPython 3.13Windows x86-64

sevent-0.4.38-cp312-cp312-win_amd64.whl (84.9 kB view details)

Uploaded CPython 3.12Windows x86-64

sevent-0.4.38-cp311-cp311-win_amd64.whl (84.7 kB view details)

Uploaded CPython 3.11Windows x86-64

sevent-0.4.38-cp310-cp310-win_amd64.whl (84.7 kB view details)

Uploaded CPython 3.10Windows x86-64

sevent-0.4.38-cp39-cp39-win_amd64.whl (85.0 kB view details)

Uploaded CPython 3.9Windows x86-64

sevent-0.4.38-cp38-cp38-win_amd64.whl (85.2 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

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

File metadata

  • Download URL: sevent-0.4.38.tar.gz
  • Upload date:
  • Size: 56.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38.tar.gz
Algorithm Hash digest
SHA256 70cb61c43323f3249adf6960c272506b8d262b337d612d8370bb6a496fcc8e17
MD5 bd406864df93f38379644af207fd02bc
BLAKE2b-256 3aa21b0b8aef410db05b942d336cdb5a40d4f3de58d3d71e80498aa7d8565247

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.38-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 84.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c8e0420f63a00a25e08c9d53a14d5ef34b9ca1fa8f5d3d665def9cdbc02ab485
MD5 810f9c4eb9d11b4441cb30d9317ba31a
BLAKE2b-256 2010503dc3b2b66ba82458e6a4d485645035f84675d5e6683ba6c81a35599477

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.38-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 84.9 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ad4acdd786c0874bf625adbec68615a0ba5251e374276745361cfa45317a7155
MD5 3f61e150abcd4b033ba1b3e4c63983df
BLAKE2b-256 412da1323b81fdad9e82ce7a0fe51a1a0b4f9e6002a35b6274eacb7c62882717

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.38-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 84.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 83aa955603463da11dbdcf73eae46a6a04ec119f79449535865170ca4a21a388
MD5 43b73e69a630511e0da55713b0871d99
BLAKE2b-256 1fda215ee0c603acc4152331da000b11a7b1bad101746fd1ae8200bb7d1d249c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.38-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 84.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 10f33da37e9d451cb6cb538f299b19a3345012a69b4327f968f47824a97e59cd
MD5 6f3c53843a6d21881dc63c6a01b0a434
BLAKE2b-256 66486084444951157a1d77f4912d61c89049464d54cbe9de8aa41358eae81a8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.38-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 85.0 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 dd11582ee1173bc290969309c509ac92e9b3033ea6203b923c06acb765406b22
MD5 8ac1dda72be0877ba46ad879fd5fd67c
BLAKE2b-256 cc22391bdd6550f356fa5fe12fe7a082fc8a1b2882ed47c2121f5a30737d5173

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.38-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 85.2 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10

File hashes

Hashes for sevent-0.4.38-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 31efe6353305b8da7d67ce30794daef6a90195aefa49b020e8ef1537ef2ea344
MD5 bd427d7b538fe67268b42a867a92e81d
BLAKE2b-256 1cd7d00d3b9633864bdbe23b307407e042637b9f856517fb2b96b50eb087c3b4

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