![]() Scrutiny: whenever you execute a checkpoint, you need to be prepared Why? First, because checkpoints require extra When writing Trio code, you need to keep track of where yourĬheckpoints are. Scheduler always switches at every checkpoint. (Currently, this check is very simple: the To see if it’s a good time to switch to another task, and It’s a point where the Trio scheduler checks its scheduling policy SeeĬancellation and timeouts below for more details. Has expired, then the next time your function executes a checkpoint The code that called your function set a timeout, and that timeout It’s a point where Trio checks for cancellation. Many of Trio’s functions act as checkpoints. When writing code using Trio, it’s very important to understand theĬoncept of a checkpoint. This is a bug and you should let us know.Īnything else – if async_fn raises an exception, then run() TrioInternalError – if an unexpected error is encountered inside Trio’s This will eventually become the default behavior. Strict_exception_groups ( bool) – If true, nurseries will always wrap even a single Main thread (this is a Python limitation), or if you use SIGINT handler, or if run() is called from anywhere but the This setting has no effect if your program has registered a custom Places where you already have to worry about Cancelled. Have to worry about KeyboardInterrupt at the exact same Program in an inconsistent state, because it means that you only KeyboardInterrupt at just the wrong place leaving your The alternative behavior is nice if you’re paranoid about a The default behavior is nice because it means that even if youĪccidentally write an infinite loop that never executes anyĬheckpoints, then you can still break out of it using control-C. Alternatively, if you set thisĪrgument to True, then KeyboardInterrupt delivery will beĭelayed: it will be only be raised at checkpoints, like a Cancelled exception. Whatever task is running (or if no task is running, then Trio will KeyboardInterrupt exception will immediately interrupt Is False (the default), then you get the standard Python behavior: a User hits control-C while run() is running? If this argument Restrict_keyboard_interrupt_to_checkpoints ( bool) – Modified during the run see Instrument API. Instrumentation you want to apply to this run. Pass keyword arguments, then use functools.partial().Ĭlock – None to use the default system-specific monotonic clock ParametersĪrgs – Positional arguments to be passed to async_fn. Requires that you be inside a call to run(). Contributing to Trio and related projectsĮxcept that run() can (and must) be called from a synchronous.Introspecting and extending Trio with trio.lowlevel.Getting back into the Trio thread from another thread.Putting blocking I/O into worker threads.Trio’s philosophy about managing worker threads.Managing multiple producers and/or multiple consumers.Using channels to pass values between tasks.Synchronizing and communicating between tasks. ![]() Spawning tasks without becoming a parent.“Strict” versus “loose” ExceptionGroup semantics.Tasks let you do multiple things at once.Trio's friendly, yet comprehensive, manual: ![]()
0 Comments
Leave a Reply. |