(entered: threading.Event, release: threading.Event, builds: List[str])
| 1144 | |
| 1145 | |
| 1146 | def _model_with_slow_build(entered: threading.Event, release: threading.Event, builds: List[str]) -> Any: |
| 1147 | from pydantic_core import core_schema |
| 1148 | |
| 1149 | owner = os.getpid() |
| 1150 | |
| 1151 | class Slow(str): |
| 1152 | @classmethod |
| 1153 | def __get_pydantic_core_schema__(cls, source: Any, handler: Any) -> Any: |
| 1154 | # A forked child must not touch these events: another thread may have held their locks at the fork. |
| 1155 | if os.getpid() == owner: |
| 1156 | builds.append(threading.current_thread().name) |
| 1157 | entered.set() |
| 1158 | release.wait(10) |
| 1159 | return core_schema.str_schema() |
| 1160 | |
| 1161 | class Model(BaseModel): |
| 1162 | # scripts/test sets DEFER_PYDANTIC_BUILD=false, so defer this model's build explicitly |
| 1163 | model_config = {"defer_build": True} |
| 1164 | name: Slow |
| 1165 | |
| 1166 | return Model |
| 1167 | |
| 1168 | |
| 1169 | @pytest.mark.skipif(PYDANTIC_V1, reason="defer_build is only supported in pydantic v2") |
no outgoing calls
no test coverage detected