Skip to content
This repository was archived by the owner on Feb 20, 2026. It is now read-only.

Commit 266badb

Browse files
committed
Add section about concurrency
1 parent f042601 commit 266badb

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

docs/index.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,22 @@ Testing
411411
def test_foo(message_recorder):
412412
foo()
413413
assert message_recorder.find("foo stuff")
414+
415+
Using cli-ui in concurrent programs
416+
-----------------------------------
417+
418+
Thanks to the `GIL <https://wiki.python.org/moin/GlobalInterpreterLock>`_, it's
419+
*usually* fine to use cli-ui in concurrent contexts.
420+
421+
However, be careful when using code like this::
422+
423+
cli_ui.info("Some thing that starts here", end=" ")
424+
cli_ui.info("and ends there")
425+
426+
It's possible for a race condition to occur that would clutter
427+
standard output if some other code prints anything between to two
428+
`cli_ui.info` calls.
429+
430+
One way to fix the problems is to use *locks*. You can see examples of
431+
this in the `examples/ folder of the repository of this project
432+
<https://github.com/dmerejkowsky/python-cli-ui/tree/main/examples>`_.

0 commit comments

Comments
 (0)