Skip to main content

Select made easy

Project description

selectz
=======

-----

.. contents:: **Table of Contents**
:backlinks: none

Installation
------------

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 socket

sel = 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.0

at your option.

.. _PYPI: https://pypi-hypernode.com
.. _example: https://docs.python.org/3/library/selectors.html
.. _MIT: https://choosealicense.com/licenses/mit
.. _Apache: https://choosealicense.com/licenses/apache-2.0

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

selectz-1.0.1.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file selectz-1.0.1.tar.gz.

File metadata

  • Download URL: selectz-1.0.1.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for selectz-1.0.1.tar.gz
Algorithm Hash digest
SHA256 98299f58db3a54971927064719674c2ecaed2349f9e0f699c0fcec7122e13b02
MD5 a0d6363beccbc79d4bd2df4d0d02b78c
BLAKE2b-256 278112234b31baee0ebe94b699bfc5dce8b8e9e130ddb06bf27337436bd24c17

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page