[core/input] Move from select to epoll

Use epoll instead of select in order to be able to use level-triggered
semantics and not get stuck on the first event.
This commit is contained in:
Tobi-wan Kenobi 2016-12-17 07:43:38 +01:00
parent 31f9154be2
commit f6be25bc73
11 changed files with 67 additions and 48 deletions

View file

@ -24,7 +24,7 @@ class TestBrightnessModule(unittest.TestCase):
for widget in self.module.widgets():
self.assertEquals(len(widget.full_text()), len("100%"))
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_wheel_up(self, mock_input, mock_output, mock_select):
@ -33,7 +33,7 @@ class TestBrightnessModule(unittest.TestCase):
"xbacklight +2%"
)
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_wheel_down(self, mock_input, mock_output, mock_select):
@ -42,7 +42,7 @@ class TestBrightnessModule(unittest.TestCase):
"xbacklight -2%"
)
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_custom_step(self, mock_input, mock_output, mock_select):

View file

@ -7,7 +7,7 @@ import mock
import bumblebee.input
from bumblebee.input import I3BarInput
from bumblebee.modules.cmus import Module
from tests.util import MockEngine, MockConfig, assertPopen
from tests.util import MockEngine, MockConfig, assertPopen, MockEpoll
class TestCmusModule(unittest.TestCase):
def setUp(self):
@ -29,7 +29,7 @@ class TestCmusModule(unittest.TestCase):
def test_widgets(self):
self.assertTrue(len(self.module.widgets()), 5)
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_interaction(self, mock_input, mock_output, mock_select):
@ -41,7 +41,8 @@ class TestCmusModule(unittest.TestCase):
{"widget": "cmus.main", "action": "cmus-remote -u"},
]
mock_select.return_value = (1,2,3)
mock_input.fileno.return_value = 1
mock_select.return_value = MockEpoll()
for event in events:
mock_input.readline.return_value = json.dumps({

View file

@ -22,7 +22,7 @@ class TestCPUModule(unittest.TestCase):
for widget in self.module.widgets():
self.assertEquals(len(widget.full_text()), len("100.00%"))
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_leftclick(self, mock_input, mock_output, mock_select):

View file

@ -7,7 +7,7 @@ import mock
import bumblebee.input
from bumblebee.input import I3BarInput
from bumblebee.modules.disk import Module
from tests.util import MockEngine, MockConfig, assertPopen, assertStateContains
from tests.util import MockEngine, MockConfig, assertPopen, assertStateContains, MockEpoll
class MockVFS(object):
def __init__(self, perc):
@ -24,7 +24,7 @@ class TestDiskModule(unittest.TestCase):
self.config.set("disk.path", "somepath")
self.module = Module(engine=self.engine, config={"config": self.config})
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_leftclick(self, mock_input, mock_output, mock_select):
@ -33,7 +33,7 @@ class TestDiskModule(unittest.TestCase):
"button": bumblebee.input.LEFT_MOUSE,
"instance": None
})
mock_select.return_value = (1,2,3)
mock_select.return_value = MockEpoll()
self.engine.input.start()
self.engine.input.stop()
mock_input.readline.assert_any_call()

View file

@ -17,7 +17,7 @@ class TestLoadModule(unittest.TestCase):
self.config = MockConfig()
self.module = Module(engine=self.engine, config={ "config": self.config })
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_leftclick(self, mock_input, mock_output, mock_select):

View file

@ -21,7 +21,7 @@ class TestMemoryModule(unittest.TestCase):
self.config = MockConfig()
self.module = Module(engine=self.engine, config={ "config": self.config })
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_leftclick(self, mock_input, mock_output, mock_select):

View file

@ -17,7 +17,7 @@ class TestPulseAudioModule(unittest.TestCase):
self.config = MockConfig()
self.module = Module(engine=self.engine, config={ "config": self.config })
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_leftclick(self, mock_input, mock_output, mock_select):
@ -26,7 +26,7 @@ class TestPulseAudioModule(unittest.TestCase):
"pactl set-source-mute @DEFAULT_SOURCE@ toggle"
)
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_rightclick(self, mock_input, mock_output, mock_select):
@ -35,7 +35,7 @@ class TestPulseAudioModule(unittest.TestCase):
"pavucontrol"
)
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_wheelup(self, mock_input, mock_output, mock_select):
@ -44,7 +44,7 @@ class TestPulseAudioModule(unittest.TestCase):
"pactl set-source-volume @DEFAULT_SOURCE@ +2%"
)
@mock.patch("select.select")
@mock.patch("select.epoll")
@mock.patch("subprocess.Popen")
@mock.patch("sys.stdin")
def test_wheeldown(self, mock_input, mock_output, mock_select):