<commit_before>"""ZMQ pooler for asyncio."""


__all__ = ['ZmqSelector']


from asyncio.selectors import BaseSelector, SelectorKey, EVENT_READ, EVENT_WRITE
from collections import Mapping
from errno import EINTR
from zmq import (ZMQError, POLLIN, POLLOUT, POLLERR,
                 Socket as ZMQSocket, Poller as ZMQPoller)


def _fileobj_to_fd(fileobj):
    """Return a file descriptor from a file object.

    Parameters:
    fileobj -- file object or file descriptor

    Returns:
    corresponding file descriptor or zmq.Socket instance

    Raises:
    ValueError if the object is invalid
    """
    if isinstance(fileobj, int):
        fd = fileobj
    elif isinstance(fileobj, ZMQSocket):
        return fileobj
    else:
        try:<commit_msg>added try/except for selectors import since selectors was moved out of asyncio in python 3.4<commit_after>"""ZMQ pooler for asyncio."""


__all__ = ['ZmqSelector']

try:
    from asyncio.selectors import BaseSelector, SelectorKey, EVENT_READ, EVENT_WRITE
except ImportError:
    from selectors import BaseSelector, SelectorKey, EVENT_READ, EVENT_WRITE
from collections import Mapping
from errno import EINTR
from zmq import (ZMQError, POLLIN, POLLOUT, POLLERR,
                 Socket as ZMQSocket, Poller as ZMQPoller)


def _fileobj_to_fd(fileobj):
    """Return a file descriptor from a file object.

    Parameters:
    fileobj -- file object or file descriptor

    Returns:
    corresponding file descriptor or zmq.Socket instance

    Raises:
    ValueError if the object is invalid
    """
    if isinstance(fileobj, int):
        fd = fileobj
    elif isinstance(fileobj, ZMQSocket):
        return fileobj
    else:
        try:
{'fraction_non_alphanumeric': 0.06678486997635934, 'fraction_numerical': 0.001182033096926714, 'mean_word_length': 3.296954314720812, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '186764', 'n_tokens_mistral': 511, 'n_tokens_neox': 478, 'n_words': 177}