-
Notifications
You must be signed in to change notification settings - Fork 6
/
poll_object.py
34 lines (26 loc) · 869 Bytes
/
poll_object.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## @package PyHoot.poll_object
# Select API for async_io.
## @file poll_object.py Implementation of @ref PyHoot.poll_object
import select
from . import base
class Poll(base.Base):
"""
Poll protocol for async_io.
Return events in Poll protocol
Args:
self._poll, the current Poll objects
"""
def __init__(self):
"""initialization"""
super(Poll, self).__init__()
self._poll = select.poll()
def register(self, fd_socket, eventmask):
"""Register a file descriptor
Args:
fd_socket: list of [file_descriptor of socket, socket]
eventmask: The events we want to register it with (poll protocol)
"""
self._poll.register(fd_socket[0], eventmask)
def poll(self):
"""Do poll on the registered file descriptors"""
return self._poll.poll()