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
sevent-0.4.25.tar.gz
(46.0 kB
view details)
Built Distributions
File details
Details for the file sevent-0.4.25.tar.gz
.
File metadata
- Download URL: sevent-0.4.25.tar.gz
- Upload date:
- Size: 46.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c34783706e44823286c5538aee651e8c9a7bd40b613453899e4fc13286ed9924 |
|
MD5 | feb842a9db76f861e137fc408de31449 |
|
BLAKE2b-256 | a09f5013bcebe831603429c0fd5f42d92a3cf32df944cb943fbaf34ccc500751 |
File details
Details for the file sevent-0.4.25-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: sevent-0.4.25-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 73.4 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 047c457a4d8fef2c7cd6e0be620f48461917b7a6bd9d428a9d1443f16a5c72c3 |
|
MD5 | 5160956c43ce78c95c919e7cc5eb6195 |
|
BLAKE2b-256 | 488ad09f1010937b12c3e2c0ca69cdd9bc6a8ce43c3e038b3237c6e8a06e2176 |
File details
Details for the file sevent-0.4.25-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: sevent-0.4.25-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 73.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b9ce3cf10f99910aa8fa02a912e6625183b171f27a0674ab8212f70ff4c964 |
|
MD5 | 5b126f8887fc6d70f403d4a4d0c15631 |
|
BLAKE2b-256 | d517d21be0442f74e86c5380a2fff097b1808b3ef71f5a8b49ca2fbec8a5823d |
File details
Details for the file sevent-0.4.25-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: sevent-0.4.25-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 73.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55e7d28cef1e3490bf2c2377366c899bb50bcb346a8fe72d801e8aa171232826 |
|
MD5 | 00390f588a4db7a39472c011036f24d6 |
|
BLAKE2b-256 | afc9b91749a483f761d763aa2864d82e146fc4fc6ab3e0dca3295904e98220b8 |
File details
Details for the file sevent-0.4.25-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: sevent-0.4.25-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 73.5 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25d1cd2f82676374b527965eaccbbac47a56ef51fb09d34bd4c33c7b4cfac464 |
|
MD5 | c43fc904e585206e977d912da8d3e1b6 |
|
BLAKE2b-256 | 6ada7cd15127b099c1cb2c41d5f43275ad49a9ea5538397cefb0b9b72164ee60 |
File details
Details for the file sevent-0.4.25-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: sevent-0.4.25-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 73.9 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76828629271e45b27ca946ee4ba27fe52e8c231a1e77fa3e47f0ffe8e537ae5d |
|
MD5 | 1af999a33c9692402f9fab4cdafbb46a |
|
BLAKE2b-256 | 5d89a08329a9b35f48f0e63450be8ecd0a8448b46d61c9802d98dd1292bfc0ad |
File details
Details for the file sevent-0.4.25-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: sevent-0.4.25-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 72.8 kB
- Tags: CPython 3.7m, 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0597a9ee834f526882d14ba66e637c76e1c1fb977b2a0cd30c33130c00427f5 |
|
MD5 | c0895fc12966ab741b0d874faf3fd9f2 |
|
BLAKE2b-256 | d348bb3ea3d6e27cb87fc4ef9343ade3721f6fb57f834ef3583412e37a084232 |