# Path: evergreen/core/socketpair.py
# class SocketPair(object):
# 
#     def __init__(self):
#         self._reader, self._writer = socketpair()
#         self._reader.setblocking(False)
#         self._writer.setblocking(False)
# 
#     def reader_fileno(self):
#         return self._reader.fileno()
# 
#     def writer_fileno(self):
#         return self._writer.fileno()
# 
#     def close(self):
#         self._reader.close()
#         self._writer.close()
# 
# Path: evergreen/core/threadpool.py
# class ThreadPool(object):
# 
#     def __init__(self, loop):
#         self.loop = loop
# 
#     def spawn(self, func, *args, **kwargs):
#         fut = Future()
#         work = _Work(func, *args, **kwargs)
#         def after(error):
#             if error is not None:
#                 assert error == pyuv.errno.UV_ECANCELLED
#                 return
#             if work.exc is not None:
#                 fut.set_exception(work.exc)
#             else:
#                 fut.set_result(work.result)
#         fut.set_running_or_notify_cancel()
#         self.loop._loop.queue_work(work, after)
#         return fut


import os
import pyuv
import sys
import threading
import traceback
    import signal
    from time import monotonic as _time
    from time import time as _time
from collections import deque
from fibers import Fiber
from functools import partial
from evergreen.core.socketpair import SocketPair
from evergreen.core.threadpool import ThreadPool
                    self._add_callback(poll_h.write_handler)
            return

        old_events = poll_h.pevents
        modified = False

        if events & pyuv.UV_READABLE:
            if poll_h.read_handler is not None:
                if poll_h.read_handler._cancelled:
                    self.remove_reader(fd)
                    modified = True
                else:
                    self._add_callback(poll_h.read_handler)
            else:
                poll_h.pevents &= ~pyuv.UV_READABLE
        if events & pyuv.UV_WRITABLE:
            if poll_h.write_handler is not None:
                if poll_h.write_handler._cancelled:
                    self.remove_writer(fd)
                    modified = True
                else:
                    self._add_callback(poll_h.write_handler)
            else:
                poll_h.pevents &= ~pyuv.UV_WRITABLE

        if not modified and old_events != poll_h.pevents:
            # Rearm the handle
            poll_h.start(poll_h.pevents, self._poll_cb)

    def _install_signal_checker(self):

# Path: evergreen/core/socketpair.py
# class SocketPair(object):
# 
#     def __init__(self):
#         self._reader, self._writer = socketpair()
#         self._reader.setblocking(False)
#         self._writer.setblocking(False)
# 
#     def reader_fileno(self):
#         return self._reader.fileno()
# 
#     def writer_fileno(self):
#         return self._writer.fileno()
# 
#     def close(self):
#         self._reader.close()
#         self._writer.close()
# 
# Path: evergreen/core/threadpool.py
# class ThreadPool(object):
# 
#     def __init__(self, loop):
#         self.loop = loop
# 
#     def spawn(self, func, *args, **kwargs):
#         fut = Future()
#         work = _Work(func, *args, **kwargs)
#         def after(error):
#             if error is not None:
#                 assert error == pyuv.errno.UV_ECANCELLED
#                 return
#             if work.exc is not None:
#                 fut.set_exception(work.exc)
#             else:
#                 fut.set_result(work.result)
#         fut.set_running_or_notify_cancel()
#         self.loop._loop.queue_work(work, after)
#         return fut


# Path: evergreen/core/loop.py
import os
import pyuv
import sys
import threading
import traceback
    import signal
    from time import monotonic as _time
    from time import time as _time
from collections import deque
from fibers import Fiber
from functools import partial
from evergreen.core.socketpair import SocketPair
from evergreen.core.threadpool import ThreadPool

                    self._add_callback(poll_h.write_handler)
            return

        old_events = poll_h.pevents
        modified = False

        if events & pyuv.UV_READABLE:
            if poll_h.read_handler is not None:
                if poll_h.read_handler._cancelled:
                    self.remove_reader(fd)
                    modified = True
                else:
                    self._add_callback(poll_h.read_handler)
            else:
                poll_h.pevents &= ~pyuv.UV_READABLE
        if events & pyuv.UV_WRITABLE:
            if poll_h.write_handler is not None:
                if poll_h.write_handler._cancelled:
                    self.remove_writer(fd)
                    modified = True
                else:
                    self._add_callback(poll_h.write_handler)
            else:
                poll_h.pevents &= ~pyuv.UV_WRITABLE

        if not modified and old_events != poll_h.pevents:
            # Rearm the handle
            poll_h.start(poll_h.pevents, self._poll_cb)

    def _install_signal_checker(self):

        self._socketpair = SocketPair()