MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / submit

Method submit

pager_lib/tqdm/contrib/utils_worker.py:22–38  ·  view source on GitHub ↗

`func(*args, **kwargs)` may replace currently waiting task.

(self, func, *args, **kwargs)

Source from the content-addressed store, hash-verified

20 self.futures = deque([], 2)
21
22 def submit(self, func, *args, **kwargs):
23 """`func(*args, **kwargs)` may replace currently waiting task."""
24 futures = self.futures
25 if len(futures) == futures.maxlen:
26 running = futures.popleft()
27 if not running.done():
28 if len(futures): # clear waiting
29 waiting = futures.pop()
30 waiting.cancel()
31 futures.appendleft(running) # re-insert running
32 try:
33 waiting = self.pool.submit(func, *args, **kwargs)
34 except Exception as e:
35 tqdm_auto.write(str(e))
36 else:
37 futures.append(waiting)
38 return waiting

Callers 8

_run_scanMethod · 0.80
_socket_scan_fallbackMethod · 0.80
writeMethod · 0.80
deleteMethod · 0.80
writeMethod · 0.80
writeMethod · 0.80
deleteMethod · 0.80

Calls 4

popMethod · 0.80
cancelMethod · 0.80
appendMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected