Skip to content

Commit dba2eba

Browse files
committed
switch from print to logging
1 parent bf87eb7 commit dba2eba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

torch/utils/data/_utils/fetch.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@
55
"""
66

77
import asyncio
8+
import logging
89
from concurrent.futures import ThreadPoolExecutor
910

11+
# Set up logger for this module
12+
logger = logging.getLogger(__name__)
13+
1014

1115
class _BaseDatasetFetcher:
1216
def __init__(self, dataset, auto_collation, collate_fn, drop_last, num_threads=1):
@@ -31,7 +35,11 @@ async def _worker(task_queue, result_queue):
3135
)
3236
await result_queue.put((index, result))
3337
except Exception as e:
34-
print(f"Exception during fetch: {e}")
38+
logger.error(
39+
"Exception during fetch for index %s: %s (%s)",
40+
index, str(e), type(e).__name__,
41+
exc_info=True
42+
)
3543
finally:
3644
task_queue.task_done()
3745

0 commit comments

Comments
 (0)