Esempio n. 1
0
 def run_forever(self):
     """Run until stop() is called."""
     self._check_closed()
     if self.is_running():
         raise RuntimeError('Event loop is running.')
     self._owner = _get_thread_ident()
     try:
         while True:
             try:
                 self._run_once()
             except _StopError:
                 break
     finally:
         self._owner = None
Esempio n. 2
0
 def run_forever(self):
     """Run until stop() is called."""
     self._check_closed()
     if self.is_running():
         raise RuntimeError('Event loop is running.')
     self._owner = _get_thread_ident()
     try:
         while True:
             try:
                 self._run_once()
             except _StopError:
                 break
     finally:
         self._owner = None
Esempio n. 3
0
    def _check_thread(self):
        """Check that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        """
        if self._owner is None:
            return
        thread_id = _get_thread_ident()
        if thread_id != self._owner:
            raise RuntimeError(
                "Non-thread-safe operation invoked on an event loop other "
                "than the current one")
Esempio n. 4
0
    def _check_thread(self):
        """Check that the current thread is the thread running the event loop.

        Non-thread-safe methods of this class make this assumption and will
        likely behave incorrectly when the assumption is violated.

        Should only be called when (self._debug == True).  The caller is
        responsible for checking this condition for performance reasons.
        """
        if self._thread_id is None:
            return
        thread_id = _get_thread_ident()
        if thread_id != self._thread_id:
            raise RuntimeError(
                "Non-thread-safe operation invoked on an event loop other "
                "than the current one")
Esempio n. 5
0
 def run_forever(self):
     """Run until stop() is called."""
     self._check_closed()
     if self.is_running():
         raise RuntimeError('Event loop is running.')
     self._set_coroutine_wrapper(self._debug)
     self._thread_id = _get_thread_ident()
     try:
         while True:
             try:
                 self._run_once()
             except _StopError:
                 break
     finally:
         self._thread_id = None
         self._set_coroutine_wrapper(False)
Esempio n. 6
0
 def run_forever(self):
     """Run until stop() is called."""
     self._check_closed()
     if self.is_running():
         raise RuntimeError('Event loop is running.')
     self._set_coroutine_wrapper(self._debug)
     self._thread_id = _get_thread_ident()
     try:
         while True:
             try:
                 self._run_once()
             except _StopError:
                 break
     finally:
         self._thread_id = None
         self._set_coroutine_wrapper(False)