MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / iter_changes

Method iter_changes

_pydev_bundle/fsnotify/__init__.py:281–350  ·  view source on GitHub ↗

Continuously provides changes (until dispose() is called). Changes provided are tuples with the Change enum and filesystem path. :rtype: Iterable[Tuple[Change, str]]

(self)

Source from the content-addressed store, hash-verified

279 self._path_watchers = path_watchers
280
281 def iter_changes(self):
282 """
283 Continuously provides changes (until dispose() is called).
284
285 Changes provided are tuples with the Change enum and filesystem path.
286
287 :rtype: Iterable[Tuple[Change, str]]
288 """
289 while not self._disposed.is_set():
290 initial_time = time.time()
291
292 old_visit_info = self._single_visit_info
293 old_file_to_mtime = old_visit_info.file_to_mtime
294 changes = []
295 append_change = changes.append
296
297 self._single_visit_info = single_visit_info = _SingleVisitInfo()
298 for path_watcher in self._path_watchers:
299 path_watcher._check(single_visit_info, append_change, old_file_to_mtime)
300
301 # Note that we pop entries while visiting, so, what remained is what's deleted.
302 for entry in old_file_to_mtime:
303 append_change((Change.deleted, entry))
304
305 for change in changes:
306 yield change
307
308 actual_time = time.time() - initial_time
309 if self.print_poll_time:
310 print("--- Total poll time: %.3fs" % actual_time)
311
312 if actual_time > 0:
313 if self.target_time_for_single_scan <= 0.0:
314 for path_watcher in self._path_watchers:
315 path_watcher.sleep_time = 0.0
316 else:
317 perc = self.target_time_for_single_scan / actual_time
318
319 # Prevent from changing the values too much (go slowly into the right
320 # direction).
321 # (to prevent from cases where the user puts the machine on sleep and
322 # values become too skewed).
323 if perc > 2.0:
324 perc = 2.0
325 elif perc < 0.5:
326 perc = 0.5
327
328 for path_watcher in self._path_watchers:
329 if path_watcher.sleep_time <= 0.0:
330 path_watcher.sleep_time = 0.001
331 new_sleep_time = path_watcher.sleep_time * perc
332
333 # Prevent from changing the values too much (go slowly into the right
334 # direction).
335 # (to prevent from cases where the user puts the machine on sleep and
336 # values become too skewed).
337 diff_sleep_time = new_sleep_time - path_watcher.sleep_time
338 path_watcher.sleep_time += diff_sleep_time / (3.0 * len(self._path_watchers))

Callers 1

_on_runMethod · 0.80

Calls 3

_SingleVisitInfoClass · 0.85
_checkMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected