:return int: Returns the time we should be waiting for to process the next event properly.
(self)
| 49 | wait_time = self.process_handles() |
| 50 | |
| 51 | def process_handles(self): |
| 52 | """ |
| 53 | :return int: |
| 54 | Returns the time we should be waiting for to process the next event properly. |
| 55 | """ |
| 56 | with self._lock: |
| 57 | if _DEBUG: |
| 58 | pydev_log.critical("pydevd_timeout: Processing handles") |
| 59 | self._event.clear() |
| 60 | handles = self._handles |
| 61 | new_handles = self._handles = [] |
| 62 | |
| 63 | # Do all the processing based on this time (we want to consider snapshots |
| 64 | # of processing time -- anything not processed now may be processed at the |
| 65 | # next snapshot). |
| 66 | curtime = time.time() |
| 67 | |
| 68 | min_handle_timeout = None |
| 69 | |
| 70 | for handle in handles: |
| 71 | if curtime < handle.abs_timeout and not handle.disposed: |
| 72 | # It still didn't time out. |
| 73 | if _DEBUG: |
| 74 | pydev_log.critical("pydevd_timeout: Handle NOT processed: %s", handle) |
| 75 | new_handles.append(handle) |
| 76 | if min_handle_timeout is None: |
| 77 | min_handle_timeout = handle.abs_timeout |
| 78 | |
| 79 | elif handle.abs_timeout < min_handle_timeout: |
| 80 | min_handle_timeout = handle.abs_timeout |
| 81 | |
| 82 | else: |
| 83 | if _DEBUG: |
| 84 | pydev_log.critical("pydevd_timeout: Handle processed: %s", handle) |
| 85 | # Timed out (or disposed), so, let's execute it (should be no-op if disposed). |
| 86 | handle.exec_on_timeout() |
| 87 | |
| 88 | if min_handle_timeout is None: |
| 89 | return None |
| 90 | else: |
| 91 | timeout = min_handle_timeout - curtime |
| 92 | if timeout <= 0: |
| 93 | pydev_log.critical("pydevd_timeout: Expected timeout to be > 0. Found: %s", timeout) |
| 94 | |
| 95 | return timeout |
| 96 | |
| 97 | def do_kill_pydev_thread(self): |
| 98 | PyDBDaemonThread.do_kill_pydev_thread(self) |
no test coverage detected