# Path: guv/const.py
# READ = 1
# 
# WRITE = 2
# 
# Path: guv/exceptions.py
# SYSTEM_ERROR = (KeyboardInterrupt, SystemExit, SystemError)


from abc import ABCMeta, abstractmethod
from greenlet import GreenletExit
from ..const import READ, WRITE
from ..exceptions import SYSTEM_ERROR
import greenlet
import sys
import traceback
    This is required for anything depending on this interface, such as :func:`hubs.trampoline`.
    """

    @abstractmethod
    def cancel(self):
        """Cancel the timer
        """
        pass


class AbstractListener(metaclass=ABCMeta):
    def __init__(self, evtype, fd):
        """
        :param str evtype: the constant hubs.READ or hubs.WRITE
        :param int fd: fileno
        """
        assert evtype in [READ, WRITE]
        self.evtype = evtype
        self.fd = fd
        self.greenlet = greenlet.getcurrent()

    def __repr__(self):
        return '{0}({1.evtype}, {1.fd})'.format(type(self).__name__, self)

    __str__ = __repr__


class AbstractHub(greenlet.greenlet, metaclass=ABCMeta):
    def __init__(self):
        super().__init__()

# Path: guv/const.py
# READ = 1
# 
# WRITE = 2
# 
# Path: guv/exceptions.py
# SYSTEM_ERROR = (KeyboardInterrupt, SystemExit, SystemError)


# Path: guv/hubs/abc.py
from abc import ABCMeta, abstractmethod
from greenlet import GreenletExit
from ..const import READ, WRITE
from ..exceptions import SYSTEM_ERROR
import greenlet
import sys
import traceback

    This is required for anything depending on this interface, such as :func:`hubs.trampoline`.
    """

    @abstractmethod
    def cancel(self):
        """Cancel the timer
        """
        pass


class AbstractListener(metaclass=ABCMeta):
    def __init__(self, evtype, fd):
        """
        :param str evtype: the constant hubs.READ or hubs.WRITE
        :param int fd: fileno
        """
        assert evtype in [READ, WRITE]
        self.evtype = evtype
        self.fd = fd
        self.greenlet = greenlet.getcurrent()

    def __repr__(self):
        return '{0}({1.evtype}, {1.fd})'.format(type(self).__name__, self)

    __str__ = __repr__


class AbstractHub(greenlet.greenlet, metaclass=ABCMeta):
    def __init__(self):
        super().__init__()

        self.listeners = {READ: {}, WRITE: {}}