# Path: cherrypy/_cpcompat.py
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
# def assert_native(n):
# def base64_decode(n, encoding='ISO-8859-1'):
#     def sorted(i):
#     def reversed(x):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def HTTPDate(timeval=None):
#     def unquote_qs(atom, encoding, errors='strict'):
#     def unquote_qs(atom, encoding, errors='strict'):
#         def json_decode(s):
#         def _json_encode(s):
#         def json_encode(value):
#     def random20():
#     def random20():
#     def next(i):
#     def __get_daemon(self):
#     def __set_daemon(self, daemon):
# class SetDaemonProperty:


import os
import re
import signal as _signal
import sys
import time
import threading
    import pwd, grp
from cherrypy._cpcompat import basestring, get_daemon, get_thread_ident, ntob, set, Timer, SetDaemonProperty
    'stop_thread' listeners for you when it stops.
    """

    threads = None
    """A map of {thread ident: index number} pairs."""

    def __init__(self, bus):
        self.threads = {}
        SimplePlugin.__init__(self, bus)
        self.bus.listeners.setdefault('acquire_thread', set())
        self.bus.listeners.setdefault('start_thread', set())
        self.bus.listeners.setdefault('release_thread', set())
        self.bus.listeners.setdefault('stop_thread', set())

    def acquire_thread(self):
        """Run 'start_thread' listeners for the current thread.

        If the current thread has already been seen, any 'start_thread'
        listeners will not be run again.
        """
        thread_ident = get_thread_ident()
        if thread_ident not in self.threads:
            # We can't just use get_ident as the thread ID
            # because some platforms reuse thread ID's.
            i = len(self.threads) + 1
            self.threads[thread_ident] = i
            self.bus.publish('start_thread', i)

    def release_thread(self):
        """Release the current thread and run 'stop_thread' listeners."""

# Path: cherrypy/_cpcompat.py
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
#     def ntob(n, encoding='ISO-8859-1'):
#     def ntou(n, encoding='ISO-8859-1'):
#     def tonative(n, encoding='ISO-8859-1'):
# def assert_native(n):
# def base64_decode(n, encoding='ISO-8859-1'):
#     def sorted(i):
#     def reversed(x):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def get_daemon(t):
#     def set_daemon(t, val):
#     def HTTPDate(timeval=None):
#     def unquote_qs(atom, encoding, errors='strict'):
#     def unquote_qs(atom, encoding, errors='strict'):
#         def json_decode(s):
#         def _json_encode(s):
#         def json_encode(value):
#     def random20():
#     def random20():
#     def next(i):
#     def __get_daemon(self):
#     def __set_daemon(self, daemon):
# class SetDaemonProperty:


# Path: cherrypy/process/plugins.py
import os
import re
import signal as _signal
import sys
import time
import threading
    import pwd, grp
from cherrypy._cpcompat import basestring, get_daemon, get_thread_ident, ntob, set, Timer, SetDaemonProperty

    'stop_thread' listeners for you when it stops.
    """

    threads = None
    """A map of {thread ident: index number} pairs."""

    def __init__(self, bus):
        self.threads = {}
        SimplePlugin.__init__(self, bus)
        self.bus.listeners.setdefault('acquire_thread', set())
        self.bus.listeners.setdefault('start_thread', set())
        self.bus.listeners.setdefault('release_thread', set())
        self.bus.listeners.setdefault('stop_thread', set())

    def acquire_thread(self):
        """Run 'start_thread' listeners for the current thread.

        If the current thread has already been seen, any 'start_thread'
        listeners will not be run again.
        """
        thread_ident = get_thread_ident()
        if thread_ident not in self.threads:
            # We can't just use get_ident as the thread ID
            # because some platforms reuse thread ID's.
            i = len(self.threads) + 1
            self.threads[thread_ident] = i
            self.bus.publish('start_thread', i)

    def release_thread(self):
        """Release the current thread and run 'stop_thread' listeners."""

        thread_ident = get_thread_ident()