Skip to content

Commit

Permalink
drop custom epoll implementation since we only support Python 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dusty Phillips committed Jan 24, 2010
1 parent 9a590d6 commit 639fe53
Showing 1 changed file with 7 additions and 35 deletions.
42 changes: 7 additions & 35 deletions psyclone/ioloop.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python
#
# Copyright 2009 Facebook
# Copyright 2010 Dusty Phillips
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
Expand Down Expand Up @@ -317,28 +318,6 @@ def _run(self):
self.start()


class _EPoll(object):
"""An epoll-based event loop using our C module for Python 2.5 systems"""
_EPOLL_CTL_ADD = 1
_EPOLL_CTL_DEL = 2
_EPOLL_CTL_MOD = 3

def __init__(self):
self._epoll_fd = epoll.epoll_create()

def register(self, fd, events):
epoll.epoll_ctl(self._epoll_fd, self._EPOLL_CTL_ADD, fd, events)

def modify(self, fd, events):
epoll.epoll_ctl(self._epoll_fd, self._EPOLL_CTL_MOD, fd, events)

def unregister(self, fd):
epoll.epoll_ctl(self._epoll_fd, self._EPOLL_CTL_DEL, fd, 0)

def poll(self, timeout):
return epoll.epoll_wait(self._epoll_fd, int(timeout * 1000))


class _KQueue(object):
"""A kqueue-based event loop for BSD/Mac systems."""
def __init__(self):
Expand Down Expand Up @@ -415,21 +394,14 @@ def poll(self, timeout):
return list(events.items())


# Choose a poll implementation. Use epoll if it is available, fall back to
# select() for non-Linux platforms
if hasattr(select, "epoll"):
# Python 2.6+ on Linux
# Choose a poll implementation. Use epoll if it is available, KQueue otherwise.
# Fall back to select() for non-Linux platforms
try:
_poll = select.epoll
elif hasattr(select, "kqueue"):
# Python 2.6+ on BSD or Mac
_poll = _KQueue
else:
except AttributeError:
try:
# Linux systems with our C module installed
import epoll
_poll = _EPoll
except:
# All other systems
_poll = _KQueue
except AttributeError:
import sys
if "linux" in sys.platform:
logging.warning("epoll module not found; using select()")
Expand Down

0 comments on commit 639fe53

Please sign in to comment.