{"id":24571,"library":"selectors2","title":"selectors2","description":"Back-ported, durable, and portable selectors module for Python. Current version 2.0.2. Maintained but stable; rarely updated.","status":"maintenance","version":"2.0.2","language":"python","source_language":"en","source_url":"https://github.com/sethmlarson/selectors2","tags":["selectors","backport","i/o","multiplexing"],"install":[{"cmd":"pip install selectors2","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"selectors2 provides its own copy; using stdlib may lack fixes and support.","wrong":"from selectors import DefaultSelector","symbol":"DefaultSelector","correct":"from selectors2 import DefaultSelector"}],"quickstart":{"code":"import selectors2\nimport socket\n\nsel = selectors2.DefaultSelector()\nsock = socket.socket()\nsock.bind(('localhost', 1234))\nsock.listen()\nsel.register(sock, selectors2.EVENT_READ)\nwhile True:\n    events = sel.select(timeout=1)\n    for key, mask in events:\n        conn, addr = key.fileobj.accept()\n        print(f'Connection from {addr}')","lang":"python","description":"Create a DefaultSelector and register a listening socket for read events."},"warnings":[{"fix":"Test thoroughly on target platform; consider using stdlib if Python >=3.4 and no exotic platform needed.","message":"selectors2 is not a drop-in replacement for the stdlib selectors module. It may behave differently on exotic platforms.","severity":"gotcha","affected_versions":"all"},{"fix":"Migrate to Python 3.","message":"Python 2 long integers are supported but Python 2 itself is EOL. Upcoming versions may drop Python 2 support.","severity":"deprecated","affected_versions":"2.0.2"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install selectors2 and use 'from selectors2 import DefaultSelector'.","cause":"Importing from stdlib 'selectors' instead of 'selectors2'.","error":"AttributeError: module 'selectors' has no attribute 'DefaultSelector'"},{"fix":"Check platform support; consider using a different I/O multiplexing library.","cause":"Platform does not support any selector (e.g., very minimal environment).","error":"RuntimeError: No selector implementation available"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}