{"id":1475,"library":"eventlet","title":"Eventlet","description":"Eventlet is a concurrent networking library for Python that uses coroutines (greenlets) and non-blocking I/O (epoll/libevent) to enable blocking-style programming in a highly scalable, asynchronous environment. As of version 0.41.0, Eventlet is in maintenance mode, discouraging new projects from using it and planning for its eventual retirement in favor of `asyncio` due to compatibility issues with newer Python versions and a growing gap in maintenance.","status":"deprecated","version":"0.41.0","language":"python","source_language":"en","source_url":"https://github.com/eventlet/eventlet","tags":["concurrency","networking","greenlets","async-io","monkey-patching"],"install":[{"cmd":"pip install eventlet","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"Calling `monkey_patch()` early in your application's lifecycle, before other imports, is crucial to ensure all standard library blocking calls are patched correctly.","symbol":"monkey_patch","correct":"import eventlet\neventlet.monkey_patch()"},{"note":"Use `eventlet.spawn` to create greenlets for concurrent execution, not standard Python threads, which are not cooperative.","wrong":"import threading\nthreading.Thread(target=my_function).start()","symbol":"spawn","correct":"import eventlet\neventlet.spawn(my_function, arg1, arg2)"},{"note":"`eventlet.sleep()` cooperatively yields control to the Eventlet hub, allowing other greenlets to run. `time.sleep()` blocks the entire process (after monkey-patching it's patched to be non-blocking but `eventlet.sleep` is the idiomatic way).","wrong":"import time\ntime.sleep(0)","symbol":"sleep","correct":"import eventlet\neventlet.sleep(0)"}],"quickstart":{"code":"import eventlet\nfrom eventlet.green import urllib.request\nimport time\n\neventlet.monkey_patch()\n\ndef fetch_url(url):\n    print(f\"Fetching {url}...\")\n    try:\n        # urllib.request becomes non-blocking after monkey_patch()\n        response = urllib.request.urlopen(url)\n        data = response.read()\n        print(f\"Finished fetching {url}, size: {len(data)} bytes\")\n    except Exception as e:\n        print(f\"Error fetching {url}: {e}\")\n\nif __name__ == '__main__':\n    urls = [\n        'http://www.google.com',\n        'http://www.bing.com',\n        'http://www.yahoo.com',\n    ]\n\n    print(\"Starting concurrent fetches...\")\n    pool = eventlet.GreenPool()\n    for url in urls:\n        pool.spawn(fetch_url, url)\n    pool.waitall()\n    print(\"All fetches complete.\")\n\n    print(\"\\nDemonstrating concurrent sleep:\")\n    def greet(name, delay):\n        eventlet.sleep(delay) # Cooperative sleep\n        print(f\"Hello, {name} after {delay} seconds!\")\n\n    pool_sleep = eventlet.GreenPool()\n    pool_sleep.spawn(greet, \"Alice\", 2)\n    pool_sleep.spawn(greet, \"Bob\", 1)\n    pool_sleep.waitall()\n    print(\"All greetings complete.\")","lang":"python","description":"This quickstart demonstrates Eventlet's core functionality: monkey-patching the standard library for non-blocking I/O and spawning greenlets for concurrent execution. It fetches multiple URLs concurrently and then shows cooperative sleeping."},"warnings":[{"fix":"For new projects, consider using Python's built-in `asyncio` library. For existing Eventlet projects, explore migration paths (e.g., using `EVENTLET_HUB=asyncio`) as provided by Eventlet documentation.","message":"Eventlet is officially in maintenance mode, and new usages are heavily discouraged. The project aims to plan its retirement due to compatibility challenges with modern Python and a shift towards `asyncio` as the preferred concurrency model.","severity":"deprecated","affected_versions":"0.41.0+"},{"fix":"Pin your project to a compatible Python version (e.g., Python 3.11 or older) or prioritize migrating away from Eventlet to `asyncio` to leverage newer Python versions.","message":"Eventlet's monkey-patching mechanism struggles with recent Python versions (e.g., Python 3.12 and beyond), leading to internal functionalities not working correctly or causing unexpected behavior. This limits projects from adopting the latest Python improvements.","severity":"breaking","affected_versions":"Python 3.12+"},{"fix":"If migrating, transition code incrementally. When running Eventlet on the `asyncio` hub, use provided APIs to explicitly wrap calls between Eventlet and `asyncio` contexts to ensure proper handling of concurrency primitives. Avoid direct inter-mixing where possible.","message":"Mixing Eventlet green threads with `asyncio`'s async functions has known limitations. Eventlet thread locals, `eventlet.greenthread.getcurrent()`, and Eventlet locks/queues may not work correctly when interacting directly between the two concurrency models in the same thread.","severity":"gotcha","affected_versions":"All"},{"fix":"Profile memory usage under load. Consider batching tasks, optimizing greenlet creation, and, for long-term solutions, migrating to `asyncio` or `trio` which often offer more refined resource management.","message":"Eventlet's green threads can lead to excessive memory consumption and inefficient resource management, especially under heavy loads or in large-scale applications, contributing to performance bottlenecks.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"search_vec":"'0.41.0':35 'async':75 'async-io':74 'asynchron':30 'asyncio':56 'block':17,23 'blocking-styl':22 'compat':59 'concurr':5,71 'coroutin':12 'discourag':41 'due':57 'enabl':21 'environ':31 'epoll/libevent':19 'eventlet':1,2,36 'eventu':51 'favor':54 'gap':68 'greenlet':13,73 'grow':67 'high':28 'i/o':18 'io':76 'issu':60 'librari':7 'mainten':39,70 'mode':40 'monkey':78 'monkey-patch':77 'network':6,72 'new':42 'newer':62 'non':16 'non-block':15 'patch':79 'plan':48 'program':25 'project':43 'python':9,63 'retir':52 'scalabl':29 'style':24 'use':11,45 'version':34,64","created_at":"2026-04-09T03:49:32.314955+00:00","updated_at":"2026-04-16T14:52:21.552049+00:00","problems":[{"fix":"Ensure that `eventlet.monkey_patch()` is called as one of the very first actions in your application's main script, before any other modules that perform blocking I/O are imported. Updating `eventlet` and `dnspython` might also resolve it for some specific version combinations.","cause":"This error frequently occurs when `eventlet.monkey_patch()` is called too late in the application's execution, after other modules (especially those performing network I/O like `requests` or `ssl`) have already been imported, leading to conflicts in the patched functions and excessive recursion during operations, particularly with SSL.","error":"RecursionError: maximum recursion depth exceeded"},{"fix":"To use Eventlet as the asynchronous server for Flask-SocketIO, you must start your application using `socketio.run(app)` instead of `app.run()`.","cause":"This error typically arises when using Flask-SocketIO with Eventlet installed, but the Flask application is being run using the default Flask development server (`app.run()`) instead of the Eventlet-compatible server provided by Flask-SocketIO.","error":"RuntimeError: You need to use the eventlet server"},{"fix":"To resolve this, you generally need to use a Python version older than 3.12. Given Eventlet's maintenance status, the recommended long-term solution is to migrate your project to a more actively maintained asynchronous framework like `asyncio` or `gevent`.","cause":"This issue occurs because Eventlet's monkey-patching mechanism attempts to access `ssl.wrap_socket()`, a function that was removed in Python 3.12. This indicates a fundamental incompatibility between Eventlet and newer Python versions.","error":"AttributeError: module 'ssl' has no attribute 'wrap_socket'"},{"fix":"For any new projects, it is strongly recommended to use modern asynchronous libraries such as `asyncio` (built into Python) or `gevent`. For existing projects using Eventlet, plan and execute a migration to one of these actively maintained alternatives.","cause":"This warning signals that the Eventlet library is in maintenance mode, and its developers actively discourage its use for new projects due to ongoing compatibility challenges with newer Python versions and a lack of active maintenance.","error":"DeprecationWarning: Eventlet is deprecated."}],"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.41.2","cli_name":"","cli_version":null,"type":"library","homepage":"https://eventlet.net","github":"https://github.com/eventlet/eventlet","docs":"https://eventlet.readthedocs.io/","changelog":"https://github.com/eventlet/eventlet/blob/master/NEWS","pypi":"https://pypi.org/project/eventlet/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-27","next_check":"2026-07-28","install_tag":"verified"}}