removed stdout redirection for now
This commit is contained in:
@@ -10,8 +10,8 @@ def compute_stuff(num: int, pbar: sc.threading.Multibar):
|
||||
speed = random.random() * 5
|
||||
for i in pbar(range(SIZE), desc=f"num {num}"):
|
||||
time.sleep(0.05 * speed * random.random())
|
||||
if random.random() > 0.98:
|
||||
print(f"some text {i}")
|
||||
# if random.random() > 0.98:
|
||||
# print(f"some text {i}")
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import multiprocessing
|
||||
import sys
|
||||
from collections.abc import Iterable, Iterator
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum, auto
|
||||
from multiprocessing import Queue
|
||||
from threading import Lock, Thread
|
||||
from typing import NamedTuple, TypeVar, Callable, Any
|
||||
from typing import Any, Callable, NamedTuple, TypeVar
|
||||
|
||||
from tqdm import tqdm
|
||||
|
||||
import sys
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
@@ -105,7 +104,7 @@ class PositionGetter:
|
||||
def __init__(self, n_tot: int, n: int, offset: int = 0):
|
||||
self.remaining = n_tot
|
||||
self.offset = offset
|
||||
self.busy_at = [False for _ in range(n_tot)]
|
||||
self.busy_at = [False for _ in range(n)]
|
||||
|
||||
@property
|
||||
def max_pos(self) -> int:
|
||||
@@ -217,12 +216,12 @@ class Multibar:
|
||||
self.current = start
|
||||
self.queue = queue
|
||||
self.finished = False
|
||||
self.stdout = QueueStdOut(self.id, self.queue)
|
||||
# self.stdout = QueueStdOut(self.id, self.queue)
|
||||
|
||||
sys.stdout = self.stdout
|
||||
sys.stderr = self.stdout
|
||||
# sys.stdout = self.stdout
|
||||
# sys.stderr = self.stdout
|
||||
|
||||
print(sys.stdout, file=sys.__stdout__)
|
||||
# print(sys.stdout, file=sys.__stdout__)
|
||||
|
||||
def update(self, amount: float | int = 1):
|
||||
self.check_start_finish()
|
||||
@@ -234,8 +233,8 @@ class Multibar:
|
||||
|
||||
def close(self):
|
||||
self.queue.put(PBarMessage(self.id, Command.FINISHED))
|
||||
sys.stdout = sys.__stdout__
|
||||
sys.stderr = sys.__stderr__
|
||||
# sys.stdout = sys.__stdout__
|
||||
# sys.stderr = sys.__stderr__
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user