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.43.tar.gz (59.0 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.43-cp314-cp314-win_amd64.whl (86.4 kB view details)

Uploaded CPython 3.14Windows x86-64

sevent-0.4.43-cp313-cp313-win_amd64.whl (86.6 kB view details)

Uploaded CPython 3.13Windows x86-64

sevent-0.4.43-cp312-cp312-win_amd64.whl (86.6 kB view details)

Uploaded CPython 3.12Windows x86-64

sevent-0.4.43-cp311-cp311-win_amd64.whl (86.3 kB view details)

Uploaded CPython 3.11Windows x86-64

sevent-0.4.43-cp310-cp310-win_amd64.whl (86.3 kB view details)

Uploaded CPython 3.10Windows x86-64

sevent-0.4.43-cp39-cp39-win_amd64.whl (86.6 kB view details)

Uploaded CPython 3.9Windows x86-64

sevent-0.4.43-cp38-cp38-win_amd64.whl (86.8 kB view details)

Uploaded CPython 3.8Windows x86-64

File details

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

File metadata

  • Download URL: sevent-0.4.43.tar.gz
  • Upload date:
  • Size: 59.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43.tar.gz
Algorithm Hash digest
SHA256 a7cacafd0c2e4fb91eeb7b71d4c7c3859e6f41daa0c83273c7ebc73096b5f557
MD5 36a40e7e5d38ba8392aa11400b96d039
BLAKE2b-256 04dc160ed8d056bd022c195b06472c631b332769d5b653c1f6812dfc6bfca9fc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 86.4 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 a0b59daba3cc1129ca798e24d51030dda3175d09ff880cc5e66b2531dbf51335
MD5 38e99640e8ba39b5ed2360f5d750f9fd
BLAKE2b-256 ded20985b883fb9843e09685fd2d8fd4dbee91c0fafe10f959f77fb2210d2e21

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7e308c121944d80091f7f7fcd0f00e21c9ae4c3f59a0f90843dffb90ab432de9
MD5 01da0d9a588ad78121c9567cbde7c5d5
BLAKE2b-256 5355b72ad77f1a31ceec7577db8e2e8ea1218d61562ad81db682cf761d1bac63

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9f8ace22748019f5f756606a4edebe60f60ab82085384036e18ed71a9fc10abc
MD5 1a831930e062f5651e4be324da1f8b7a
BLAKE2b-256 73d1663fadc36e59860932d2b6cbea34469176cf0e855f9540407035828d3960

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d16539b0fc08b5a36ef142e7dc21f81492268143a2aaa9983e78698a55dcc0dd
MD5 a15c9a5ec791717111108e8dd208d215
BLAKE2b-256 868caea2f3288184c41af65bef1988f906f37d43e4d337301b839f16013b4a45

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 43ad66e04bee2f37108c3287aba9f9d1ca76bf812a0770cac0da5c5c8911d6d2
MD5 852412973a6b17ca182102b2d9a08c18
BLAKE2b-256 41d85e0d6556e0cccc52e6d4b19f32f36b6729134ac98d891b37b3f1ae88addb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 83bfc48dd201f4e13277026b508d097afbef5f87361cf31a55196e6a0806a508
MD5 2d621388115501f4a544babd4b2ffd8e
BLAKE2b-256 43602f2d2c9eaf24d706a931ba85c9533d4e3bcf2b0b4e7ea732accb81aec55e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sevent-0.4.43-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 86.8 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for sevent-0.4.43-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 1619ddd8f0395495f432392e8622ee047b29dc96f5ba75ded83aefd06e5dc7cc
MD5 696788476213401bf30df55c80ca6304
BLAKE2b-256 b63943f5ae3f4a96727e4ab10fec5542c10c60aa46a651001a2b158d700b7489

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