# Path: gumpy/deco.py
# class _RequirementHepler(object):
# class _ConsumerHelper(object):
# class _EventHepler(object):
# class activate(Annotation):
# class deactivate(Annotation):
# class _TaskHelper(object):
#     def __init__(self, fn, args, kwargs):
#     def __get__(self, instance, owner):
#     def __init__(self, fn, resource_uri, cardinality):
#     def __get__(self, instance, owner):
#     def unbind(self, fn):
#     def __init__(self, fn):
#     def __get__(self, instance, owner):
# def configuration(**config_map):
#     def deco(func):
#         def configuration_injected_func(self, *args, **kwargs):
#     def subject(self):
#     def subject(self):
#     def __init__(self, fn):
#     def __get__(self, instance, owner):


import multiprocessing.pool
import functools
import wsgiref.simple_server, wsgiref.util, wsgiref.validate
import logging
from gumpy.deco import service, configuration, bind, event
    def shutdown(self):
        super(self.__class__, self).shutdown()
        self._pool.terminate()

@service
class WSGIService(object):
    @configuration(rootapp='rootapp')
    def __init__(self, rootapp):
        self._apps = {}
        self._server = None
        self._rootapp = rootapp
        self.start_wsgi_server()

    @configuration(port=('port', 8001))
    def start_wsgi_server(self, port):
        try:
            sc = functools.partial(ThreadPoolWSGIServer, 20)
            self._server = wsgiref.simple_server.make_server(
                '', port, self._wsgi_app, server_class=sc
            )
            self._server.serve_forever()
        except BaseException as err:
            err.args = ('tserv start fails.', ) + err.args
            logger.exception(err)

    def on_stop(self):
        if self._server:
            self._server.shutdown()
        del self._server


# Path: gumpy/deco.py
# class _RequirementHepler(object):
# class _ConsumerHelper(object):
# class _EventHepler(object):
# class activate(Annotation):
# class deactivate(Annotation):
# class _TaskHelper(object):
#     def __init__(self, fn, args, kwargs):
#     def __get__(self, instance, owner):
#     def __init__(self, fn, resource_uri, cardinality):
#     def __get__(self, instance, owner):
#     def unbind(self, fn):
#     def __init__(self, fn):
#     def __get__(self, instance, owner):
# def configuration(**config_map):
#     def deco(func):
#         def configuration_injected_func(self, *args, **kwargs):
#     def subject(self):
#     def subject(self):
#     def __init__(self, fn):
#     def __get__(self, instance, owner):


# Path: huacaya/tserv.py
import multiprocessing.pool
import functools
import wsgiref.simple_server, wsgiref.util, wsgiref.validate
import logging
from gumpy.deco import service, configuration, bind, event

    def shutdown(self):
        super(self.__class__, self).shutdown()
        self._pool.terminate()

@service
class WSGIService(object):
    @configuration(rootapp='rootapp')
    def __init__(self, rootapp):
        self._apps = {}
        self._server = None
        self._rootapp = rootapp
        self.start_wsgi_server()

    @configuration(port=('port', 8001))
    def start_wsgi_server(self, port):
        try:
            sc = functools.partial(ThreadPoolWSGIServer, 20)
            self._server = wsgiref.simple_server.make_server(
                '', port, self._wsgi_app, server_class=sc
            )
            self._server.serve_forever()
        except BaseException as err:
            err.args = ('tserv start fails.', ) + err.args
            logger.exception(err)

    def on_stop(self):
        if self._server:
            self._server.shutdown()
        del self._server


    @bind('tserv.application')