# 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 functools
import threading
import wsgiref.simple_server, wsgiref.util, wsgiref.validate
import logging
from gumpy.deco import service, configuration, bind, event
from util import HTTP_STATUS
# -*- coding: utf-8 -*-
__author__ = 'chinfeng'


logger = logging.getLogger(__name__)

class TaskPoolWSGIServer(wsgiref.simple_server.WSGIServer):
    def __init__(self, executor, *args, **kwds):
        wsgiref.simple_server.WSGIServer.__init__(self, *args, **kwds)
        self._executor = executor

    def process_request_coroutine(self, request, client_address):
        try:
            self.finish_request(request, client_address)
            self.shutdown_request(request)
        except:
            self.handle_error(request, client_address)
            self.shutdown_request(request)

    def process_request(self, request, client_address):
        self._executor.call(functools.partial(self.process_request_coroutine, request, client_address))


# 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/cserv.py
import functools
import threading
import wsgiref.simple_server, wsgiref.util, wsgiref.validate
import logging
from gumpy.deco import service, configuration, bind, event
from util import HTTP_STATUS

# -*- coding: utf-8 -*-
__author__ = 'chinfeng'


logger = logging.getLogger(__name__)

class TaskPoolWSGIServer(wsgiref.simple_server.WSGIServer):
    def __init__(self, executor, *args, **kwds):
        wsgiref.simple_server.WSGIServer.__init__(self, *args, **kwds)
        self._executor = executor

    def process_request_coroutine(self, request, client_address):
        try:
            self.finish_request(request, client_address)
            self.shutdown_request(request)
        except:
            self.handle_error(request, client_address)
            self.shutdown_request(request)

    def process_request(self, request, client_address):
        self._executor.call(functools.partial(self.process_request_coroutine, request, client_address))


@service