Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pdxjohnny/selectz
select made easy
https://github.com/pdxjohnny/selectz
Last synced: about 1 month ago
JSON representation
select made easy
- Host: GitHub
- URL: https://github.com/pdxjohnny/selectz
- Owner: pdxjohnny
- License: apache-2.0
- Created: 2017-09-18T22:27:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-07T23:39:20.000Z (about 7 years ago)
- Last Synced: 2024-10-11T09:20:12.518Z (about 1 month ago)
- Language: Python
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE-APACHE
Awesome Lists containing this project
README
selectz
=======-----
.. contents:: **Table of Contents**
:backlinks: noneInstallation
------------selectz is distributed on PyPI_ as a universal wheel and is available on
Linux/macOS and Windows and supports Python 2.7/3.5+ and PyPy... code-block:: bash
$ pip install selectz
Usage
-----Modified Python 3 selectors example_ using `selectz`.
.. code-block:: python
import selectz
import socketsel = selectz.Selector()
def accept(sock):
conn, addr = sock.accept() # Should be ready
print('accepted', conn, 'from', addr)
conn.setblocking(False)
sel.register('read', conn, read)def read(conn):
data = conn.recv(1000) # Should be ready
if data:
print('echoing', repr(data), 'to', conn)
conn.send(data) # Hope it won't block
else:
print('closing', conn)
sel.remove(conn)
conn.close()sock = socket.socket()
sock.bind(('localhost', 1234))
sock.listen(100)
sock.setblocking(False)
sel.register('read', sock, accept)while True:
sel.select()License
-------selectz is distributed under the terms of both
- MIT_ License
- Apache_ License, Version 2.0at your option.
.. _PYPI: https://pypi.org
.. _example: https://docs.python.org/3/library/selectors.html
.. _MIT: https://choosealicense.com/licenses/mit
.. _Apache: https://choosealicense.com/licenses/apache-2.0