관리-도구
편집 파일: selectors.cpython-34.pyo
� e f�B � @ s� d Z d d l m Z m Z d d l m Z m Z d d l Z d d l Z d d l Z d Z d Z d d � Z e d d d d d g � Z Gd d � d e � Z Gd d � d d e �Z Gd d � d e � Z Gd d � d e � Z e e d � rGd d � d e � Z n e e d � r4Gd d � d e � Z n e e d � r\Gd d � d e � Z n d e � k rte Z n6 d e � k r�e Z n d e � k r�e Z n e Z d S)!z|Selectors module. This module allows high-level and efficient I/O multiplexing, built upon the `select` module primitives. � )�ABCMeta�abstractmethod)� namedtuple�MappingN� c C s� t | t � r | } nL y t | j � � } Wn3 t t t f k rc t d j | � � d � Yn X| d k r� t d j | � � � n | S)z�Return a file descriptor from a file object. Parameters: fileobj -- file object or file descriptor Returns: corresponding file descriptor Raises: ValueError if the object is invalid zInvalid file object: {!r}Nr zInvalid file descriptor: {})� isinstance�int�fileno�AttributeError� TypeError� ValueError�format)�fileobj�fd� r �./opt/alt/python34/lib64/python3.4/selectors.py�_fileobj_to_fd s r �SelectorKeyr r �events�datac @ sF e Z d Z d Z d d � Z d d � Z d d � Z d d � Z d S)�_SelectorMappingz)Mapping of file objects to selector keys.c C s | | _ d S)N)� _selector)�selfZselectorr r r �__init__5 s z_SelectorMapping.__init__c C s t | j j � S)N)�lenr � _fd_to_key)r r r r �__len__8 s z_SelectorMapping.__len__c C sU y$ | j j | � } | j j | SWn* t k rP t d j | � � d � Yn Xd S)Nz{!r} is not registered)r �_fileobj_lookupr �KeyErrorr )r r r r r r �__getitem__; s z_SelectorMapping.__getitem__c C s t | j j � S)N)�iterr r )r r r r �__iter__B s z_SelectorMapping.__iter__N)�__name__� __module__�__qualname__�__doc__r r r r! r r r r r 2 s r c @ s� e Z d Z d Z e d d d � � Z e d d � � Z d d d � Z e d d d � � Z d d � Z d d � Z e d d � � Z d d � Z d d � Z d S)�BaseSelectora- Selector abstract base class. A selector supports registering file objects to be monitored for specific I/O events. A file object is a file descriptor or any object with a `fileno()` method. An arbitrary object can be attached to the file object, which can be used for example to store context information, a callback, etc. A selector can use various implementations (select(), poll(), epoll()...) depending on the platform. The default `Selector` class uses the most efficient implementation on the current platform. Nc C s t � d S)a3 Register a file object. Parameters: fileobj -- file object or file descriptor events -- events to monitor (bitwise mask of EVENT_READ|EVENT_WRITE) data -- attached data Returns: SelectorKey instance Raises: ValueError if events is invalid KeyError if fileobj is already registered OSError if fileobj is closed or otherwise is unacceptable to the underlying system call (if a system call is made) Note: OSError may or may not be raised N)�NotImplementedError)r r r r r r r �registerU s zBaseSelector.registerc C s t � d S)aj Unregister a file object. Parameters: fileobj -- file object or file descriptor Returns: SelectorKey instance Raises: KeyError if fileobj is not registered Note: If fileobj is registered but has since been closed this does *not* raise OSError (even if the wrapped syscall does) N)r'