Skip to content

Commit 038dba3

Browse files
committed
Implement reset_stdio_counter()
1 parent 5149234 commit 038dba3

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

docs/src/_changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Changelog](https://keepachangelog.com).
99

1010
## Unreleased
1111

12+
### Added
13+
- Implemented [`reset_stdio_count()`](@ref) to provide a public API for
14+
resetting the stdio count ([#1172]).
15+
1216
### Changed
1317
- IJulia was completely refactored to minimize global state ([#1172]). This
1418
allows for better testing (for the first time we can test kernel execution)

docs/src/library/public.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ IJulia.load_string
4545
```@docs
4646
IJulia.readprompt
4747
IJulia.set_max_stdio
48+
IJulia.reset_stdio_count
4849
```

src/IJulia.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,15 @@ function set_max_stdio(max_output::Integer; kernel)
485485
kernel.max_output_per_request[] = max_output
486486
end
487487

488+
"""
489+
reset_stdio_count()
490+
491+
Reset the count of the number of bytes written to stdout/stderr. See
492+
[`set_max_stdio`](@ref) for more details.
493+
"""
494+
function reset_stdio_count(kernel=_default_kernel)
495+
kernel.stdio_bytes = 0
496+
end
488497

489498
#######################################################################
490499

test/stdio.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,7 @@ using IJulia
3939
end
4040
end
4141

42+
kernel.stdio_bytes = 42
43+
IJulia.reset_stdio_count(kernel)
44+
@test kernel.stdio_bytes == 0
4245
end

0 commit comments

Comments
 (0)