Esempio n. 1
0
    def test_wait_timeout(self):
        # Issue #635
        from gevent import socket as gsocket
        class io(object):
            callback = None

            def start(self, *_args):
                gevent.sleep(10)

        with self.assertRaises(gsocket.timeout):
            gsocket.wait(io(), timeout=0.01) # pylint:disable=no-member
Esempio n. 2
0
 def _writer(self, inch):
     """
     This greenlet will block until messages are ready to be written to pty
     """
     try:
         sock = self._master
         for msg in inch.watch():
             if 'resize' in msg:
                 set_winsize(sock, msg['resize']['width'],
                             msg['resize']['height'])
             if 'data' in msg:
                 buf = msg['data']
                 while not self.finished and len(buf):
                     try:
                         wait(self._write_event)
                     except Exception:
                         break
                     nwritten = os.write(sock, msg['data'])
                     buf = buf[nwritten:]
     except Exception:
         LOG.exception("In Process._writer")
Esempio n. 3
0
 def run(self, task):
     writer_task = gevent.spawn(self._writer, task.input)
     gevent.spawn(self._waitclosed)
     proc = self._proc
     try:
         sock = self._master
         while not self.finished:
             try:
                 wait(self._read_event)
             except Exception:
                 break
             data = os.read(sock, 1024)
             if len(data) == 0 or data is StopIteration:
                 break
             if sock == proc.stderr:
                 task.output.send(dict(error=data))
             else:
                 task.output.send(dict(data=data))
     except Exception:
         LOG.exception("While reading from process")
     finally:
         writer_task.kill()
         self.stop()
Esempio n. 4
0
        def gevent_wait_write(self, poll=True):
            if poll and self.gevent_check_write():
                return

            self.__check_watchers()
            wait(self.gevent_write_watcher, hub=self.gevent_hub)
Esempio n. 5
0
 def gevent_wait_write(self):
     if not self.gevent_check_write():
         self.__check_watchers()
         wait(self.gevent_write_watcher, hub=self.gevent_hub)
Esempio n. 6
0
 def gevent_wait_read(self):
     if not self.gevent_check_read():
         self.__check_watchers()
         wait(self.gevent_read_watcher, hub=self.gevent_hub)