{"id":23677,"library":"ephemeral-port-reserve","title":"ephemeral-port-reserve","description":"A small Python library that binds to an ephemeral port, forces it into the TIME_WAIT state, and then unbinds, making the port reserved for use by the caller without interference. Current version 1.1.4, maintenance mode with no active development.","status":"active","version":"1.1.4","language":"python","source_language":"en","source_url":"https://github.com/Yelp/ephemeral-port-reserve","tags":["port-reservation","ephemeral","networking","testing"],"install":[{"cmd":"pip install ephemeral-port-reserve","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"This is the only public API. No common mistakes, but ensure import matches exactly.","wrong":"from ephemeral_port_reserve import reserve","symbol":"reserve","correct":"from ephemeral_port_reserve import reserve"}],"quickstart":{"code":"from ephemeral_port_reserve import reserve\n\n# Reserve an ephemeral port\nport = reserve()\nprint(f\"Reserved port: {port}\")\n# Use the port...\n# No explicit release needed; the reservation vanishes when the process exits.\n","lang":"python","description":"Reserve an ephemeral port using the reserve() function. Port is automatically released on process exit."},"warnings":[{"fix":"Ensure your process holds the reservation for the duration needed. Do not rely on cross-process persistence.","message":"The reserved port is only guaranteed to be available for the lifetime of the calling process. Once the process exits, the port may be reused by the OS or another process.","severity":"gotcha","affected_versions":"all"},{"fix":"Handle exceptions from reserve() and implement retry logic or fallback mechanisms.","message":"On some systems (e.g., Linux), the reservation may fail if the system is under heavy load or if ephemeral port range is exhausted. The function raises an exception in such cases.","severity":"gotcha","affected_versions":"all"},{"fix":"If you need more robust port reservation, consider using low-level socket APIs or platform-specific solutions.","message":"The library is in maintenance mode and is not actively developed. No new features or bug fixes are expected. Consider alternative approaches for advanced port management.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install ephemeral-port-reserve' (note hyphens) and import with underscores: 'from ephemeral_port_reserve import reserve'.","cause":"The library is not installed or the import path is incorrect.","error":"ImportError: No module named ephemeral_port_reserve"},{"fix":"The library avoids this by using time_wait state, but if it occurs, wait for the TIME_WAIT to expire (typically 2 * MSL) or use a different port. Retry reservation.","cause":"The reserved port is still in TIME_WAIT from a previous use, or another process is using it.","error":"OSError: [Errno 98] Address already in use"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}