MCPcopy
hub / github.com/psycopg/psycopg / run

Method run

psycopg_pool/psycopg_pool/sched.py:66–96  ·  view source on GitHub ↗

Execute the events scheduled.

(self)

Source from the content-addressed store, hash-verified

64 return task
65
66 def run(self) -> None:
67 """Execute the events scheduled."""
68 q = self._queue
69 while True:
70 with self._lock:
71 now = monotonic()
72 if task := (q[0] if q else None):
73 if task.time <= now:
74 heappop(q)
75 else:
76 delay = task.time - now
77 task = None
78 else:
79 delay = self.EMPTY_QUEUE_TIMEOUT
80 self._event.clear()
81
82 if task:
83 if not task.action:
84 break
85 try:
86 task.action()
87 except CLIENT_EXCEPTIONS as e:
88 logger.warning(
89 "scheduled task run %s failed: %s: %s",
90 task.action,
91 e.__class__.__name__,
92 e,
93 )
94 else:
95 # Block for the expected timeout or until a new task scheduled
96 self._event.wait(delay)

Callers 12

test_schedFunction · 0.95
run_in_containerFunction · 0.45
asyncio_runFunction · 0.45
test_geventFunction · 0.45
test_eintrFunction · 0.45
test_eintrFunction · 0.45
test_type_error_shadowFunction · 0.45
run_on_fileMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45
get_configFunction · 0.45

Calls 2

clearMethod · 0.45
waitMethod · 0.45

Tested by 6

test_schedFunction · 0.76
test_geventFunction · 0.36
test_eintrFunction · 0.36
test_eintrFunction · 0.36
test_type_error_shadowFunction · 0.36
mainFunction · 0.36