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
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 Distributions
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 sevent-0.4.42.tar.gz.
File metadata
- Download URL: sevent-0.4.42.tar.gz
- Upload date:
- Size: 59.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbe042cc84811e6852cd2985ccae13756676d0b9d1abef387334165200cb534a
|
|
| MD5 |
69b975fe4cc27a7992710a590daab073
|
|
| BLAKE2b-256 |
59ae57d06e3f313bf96ca011a9ecf522dffdb8ca300a2fcb4d5ce1a2d6330572
|
File details
Details for the file sevent-0.4.42-cp314-cp314-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-cp314-cp314-win_amd64.whl
- Upload date:
- Size: 86.5 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd5ad26b83b77085c5a431010a57ed2af765b329ed62fcc1d29b32815674263f
|
|
| MD5 |
9b3f97bfffda46badeda60927ab47fc3
|
|
| BLAKE2b-256 |
c0fbfc24c26bbc8b2ab317124c4490cdeb098dcf19839dc5e17816648997d7a6
|
File details
Details for the file sevent-0.4.42-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe1a3dda62e8030d2c3bcf593dfbd1dfb4b22d4c8f1910fd01aa61fd3fc3b3e2
|
|
| MD5 |
edd410ea9362d406ff129a245a9e523b
|
|
| BLAKE2b-256 |
584a560b1efdbacd58b1fd49375f5bf3f299843730e2516f782da7e91ce7b185
|
File details
Details for the file sevent-0.4.42-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67a4bb7444e73e8050b74381e3a37735f0dff712774c788a6c4e014950dada4c
|
|
| MD5 |
a0f97893e2b3fbf5fbc20f661b76b742
|
|
| BLAKE2b-256 |
99fb2f759dbd18f6c63579f1ed404bef34d4025a2ba1c41c23332aa3f54cd9a0
|
File details
Details for the file sevent-0.4.42-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 86.4 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1cfc5ceb401ab109a070a4dbafc732d3edd525b5db7e1b020e8e8b5fb1c51d6
|
|
| MD5 |
1f6cd2352397afb65282280a51e595e8
|
|
| BLAKE2b-256 |
d251586297ad5a99825880f036a3aab7180b8f97f0eb57d4637098879b1c038b
|
File details
Details for the file sevent-0.4.42-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 86.4 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe738f275bc0cd85fd3c036e28c5938506b104187d9a1468b022a01978db1dfd
|
|
| MD5 |
5790cc3e2ba5e018fda49de61f794c82
|
|
| BLAKE2b-256 |
038ab11e671a9c44c0365673c7ab58b15f26fa29ed233644da568d340e28321a
|
File details
Details for the file sevent-0.4.42-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 86.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
669b408979594202e77cc9cb8cde8fecb16388d5421222af6726a9639177af2e
|
|
| MD5 |
499dd4b53cc6253807cdab7c47a17e3c
|
|
| BLAKE2b-256 |
875ddacd74225545c7297bddfa2778fd21b01c834767712ae51f6a130fb65981
|
File details
Details for the file sevent-0.4.42-cp38-cp38-win_amd64.whl.
File metadata
- Download URL: sevent-0.4.42-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 86.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5558e362f86aa4eb6d7e6d7f1bd0cb0fb00c121641d700544a62ee8d109548fb
|
|
| MD5 |
0940959a6ca5761a14469edd05d8e187
|
|
| BLAKE2b-256 |
4e193d2e347d8d4101d81fe3c99320a677f3f1f207dd861242f634085848347a
|