# Copyright (c) 2009-2010 Denis Bilenko. See LICENSE for details.
"""Make the standard library cooperative.
The functions in this module patch parts of the standard library with compatible cooperative counterparts
from :mod:`gevent` package.
To patch an individual module call the corresponding ``patch_*`` function. For example, to patch
socket module only, call :func:`patch_socket`. To patch all default modules, call ``gevent.monkey.patch_all()``.
Monkey can also patch thread and threading to become greenlet-based. So :func:`thread.start_new_thread`
starts a new greenlet instead and :class:`threading.local` becomes a greenlet-local storage.
Monkey patches:
* :mod:`socket` module -- :func:`patch_socket`
- :class:`socket`
- :class:`SocketType`
- :func:`socketpair`
- :func:`fromfd`
- :func:`ssl` and :class:`sslerror`
- :func:`socket.getaddrinfo`
- :func:`socket.gethostbyname`
- It is possible to disable dns patching by passing ``dns=False`` to :func:`patch_socket` of :func:`patch_all`
- If ssl is not available (Python < 2.6 without ``ssl`` and ``PyOpenSSL`` packages installed) then :func:`ssl` is removed from the target :mod:`socket` module.
* :mod:`ssl` module -- :func:`patch_ssl`
- :class:`SSLSocket`
- :func:`wrap_socket`
- :func:`get_server_certificate`
- :func:`sslwrap_simple`
* :mod:`os` module -- :func:`patch_os`
- :func:`fork`
* :mod:`time` module -- :func:`patch_time`
- :func:`time`
* :mod:`select` module -- :func:`patch_select`
- :func:`select`
- Removes polling mechanisms that :mod:`gevent.select` does not simulate: poll, epoll, kqueue, kevent
* :mod:`thread` and :mod:`threading` modules -- :func:`patch_thread`