MCPcopy Create free account
hub / github.com/tiny-pilot/tinypilot / reschedule

Function reschedule

app/threads.py:4–17  ·  view source on GitHub ↗

Reschedules the current thread to allow other waiting threads to proceed. When carrying out longer-running operations e.g. in a while loop, the Python process is blocked by default. That means that all other threads are frozen. This problem can be avoided by frequently calling this meth

(seconds=0)

Source from the content-addressed store, hash-verified

2
3
4def reschedule(seconds=0):
5 """Reschedules the current thread to allow other waiting threads to proceed.
6
7 When carrying out longer-running operations e.g. in a while loop, the Python
8 process is blocked by default. That means that all other threads are frozen.
9 This problem can be avoided by frequently calling this method in the loop at
10 a (most likely) negligible performance penalty.
11
12 Args:
13 seconds: An integer or a float of the number of seconds to yield for.
14 """
15 # Flask uses eventlet internally. Calling `time.sleep` wouldn’t help here,
16 # since we don’t (and don’t want to) monkey-patch Python’s time API.
17 eventlet.sleep(seconds)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected