Exemple #1
0
 def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
     if _sock is None:
         self._sock = _realsocket(family, type, proto)
         self.timeout = _socket.getdefaulttimeout()
     else:
         if hasattr(_sock, '_sock'):
             self._sock = _sock._sock
             self.timeout = getattr(_sock, 'timeout', False)
             if self.timeout is False:
                 self.timeout = _socket.getdefaulttimeout()
         else:
             self._sock = _sock
             self.timeout = _socket.getdefaulttimeout()
     self._sock.setblocking(0)
     self._read_event = core.event(core.EV_READ, self.fileno(),
                                   _wait_helper)
     self._write_event = core.event(core.EV_WRITE, self.fileno(),
                                    _wait_helper)
     # regarding the following, see issue #31
     # (http://code.google.com/p/gevent/issues/detail?id=31#c19)
     if is_windows:
         self._rw_event = core.event(core.EV_READ | core.EV_WRITE,
                                     self.fileno(), _wait_helper)
     else:
         self._rw_event = core.event(core.EV_WRITE, self.fileno(),
                                     _wait_helper)
Exemple #2
0
def _init():
    global _initialized
    global _nochild
    if _initialized:
        return

    if version_info[:2] < (1, 0):
        core.event(core.EV_SIGNAL | core.EV_PERSIST, signal.SIGCHLD, got_signal).add()
    else:
        _nochild = getattr(get_hub().loop, "nochild", True)
        if _nochild:
            signal.signal(signal.SIGCHLD, got_signal)
    _initialized = True
Exemple #3
0
 def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
     if _sock is None:
         self._sock = _realsocket(family, type, proto)
         self.timeout = _socket.getdefaulttimeout()
     else:
         if hasattr(_sock, '_sock'):
             self._sock = _sock._sock
             self.timeout = getattr(_sock, 'timeout', False)
             if self.timeout is False:
                 self.timeout = _socket.getdefaulttimeout()
         else:
             self._sock = _sock
             self.timeout = _socket.getdefaulttimeout()
     self._sock.setblocking(0)
     self._read_event = core.event(core.EV_READ, self.fileno(), _wait_helper)
     self._write_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper)
     self._rw_event = core.event(core.EV_READ|core.EV_WRITE, self.fileno(), _wait_helper)
Exemple #4
0
 def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
     if _sock is None:
         self._sock = _realsocket(family, type, proto)
         self.timeout = _socket.getdefaulttimeout()
     else:
         if hasattr(_sock, '_sock'):
             self._sock = _sock._sock
             self.timeout = getattr(_sock, 'timeout', False)
             if self.timeout is False:
                 self.timeout = _socket.getdefaulttimeout()
         else:
             self._sock = _sock
             self.timeout = _socket.getdefaulttimeout()
     self._sock.setblocking(0)
     self._read_event = core.event(core.EV_READ, self.fileno(),
                                   _wait_helper)
     self._write_event = core.event(core.EV_WRITE, self.fileno(),
                                    _wait_helper)
     self._rw_event = core.event(core.EV_READ | core.EV_WRITE,
                                 self.fileno(), _wait_helper)
Exemple #5
0
 def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
     if _sock is None:
         self._sock = _realsocket(family, type, proto)
         self.timeout = _socket.getdefaulttimeout()
     else:
         if hasattr(_sock, '_sock'):
             self._sock = _sock._sock
             self.timeout = getattr(_sock, 'timeout', False)
             if self.timeout is False:
                 self.timeout = _socket.getdefaulttimeout()
         else:
             self._sock = _sock
             self.timeout = _socket.getdefaulttimeout()
     self._sock.setblocking(0)
     self._read_event = core.event(core.EV_READ, self.fileno(), _wait_helper)
     self._write_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper)
     # regarding the following, see issue #31
     # (http://code.google.com/p/gevent/issues/detail?id=31#c19)
     if is_windows:
         self._rw_event = core.event(core.EV_READ | core.EV_WRITE, self.fileno(), _wait_helper)
     else:
         self._rw_event = core.event(core.EV_WRITE, self.fileno(), _wait_helper)
Exemple #6
0
 def __init__(self, cb):
     self.cb = cb
     self.reader, self.writer = _socketpair()
     self.event = core.event(core.EV_READ | core.EV_PERSIST, self.reader.fileno(), self.eventcb)
     self.event.add()
Exemple #7
0
 def begin_notify_receive(self, callback):
     e = core.event(core.EV_READ | core.EV_PERSIST,
                    self.rfile.fileno(), self._cb_notify_read,
                    arg=callback)
     e.add()