A multi-threaded customer data processing system implemented in Python, designed to simulate customer arrivals, data processing, and record keeping workflows.
- Simulates random customer arrivals
- Multi-threaded parallel processing
- Real-time status monitoring
- CSV file recording
- Automated processing workflow
The system consists of four main components, each running in a separate thread:
-
Customer Generator (generate_customer)
- Simulates random customer arrivals
- Generates unique customer numbers
- Controls total customer count
-
Data Processor (read_card)
- Processes customer data
- Records processing timestamps
- Prepares data for storage
-
Data Storage (save_to_file)
- Writes processed data to CSV file
- Ensures data is safely stored
- Tracks saving progress
-
Status Monitor (show_status)
- Displays real-time system status
- Monitors processing progress
- Shows queue status
- Uses Python standard library
- Multi-threaded parallel processing
- Queue management mechanism
- Exception handling
- CSV file operations
- Python 3.6 or higher
- No additional packages required (standard library only)
-
Direct execution:
python customer_processing.py
-
Execution process:
- Automatically generates 5 customer records
- Displays real-time processing status
- Automatically saves to customer_log.csv
- Terminates automatically upon completion
-
Output file:
- Generates customer_log.csv in execution directory
- Contains timestamps and customer numbers
During execution, the program displays:
- Number of customers generated
- Number of customers processed
- Items pending in queue
- File writing status
- Program is designed to process a fixed number of customers (default 5)
- Customer count can be adjusted via TOTAL_CUSTOMERS variable
- Program can be interrupted using Ctrl+C
- CSV file is overwritten on each execution
customer_processing.py
├── generate_customer() # Customer Generator
├── read_card() # Data Processor
├── save_to_file() # Data Storage
├── show_status() # Status Monitor
└── main() # Main Program Entry
Improvements and bug reports are welcome. You can contribute by:
- Submitting Issues
- Suggesting Improvements
- Submitting Pull Requests
This project is licensed under the MIT License. See the LICENSE file for details.
這是一個使用 Python 多執行緒實現的顧客資料處理系統,用於模擬顧客到達、資料處理和記錄保存的流程。
- 模擬顧客隨機到達
- 多執行緒並行處理
- 即時狀態監控
- CSV 檔案記錄
- 自動化處理流程
系統包含四個主要組件,每個組件運行在獨立的執行緒中:
-
顧客生成器 (generate_customer)
- 模擬顧客隨機到達
- 生成唯一的顧客編號
- 控制總顧客數量
-
資料處理器 (read_card)
- 處理顧客資料
- 記錄處理時間戳記
- 準備待保存的資料
-
資料儲存器 (save_to_file)
- 將處理後的資料寫入 CSV 檔案
- 確保資料安全儲存
- 追踪保存進度
-
狀態監控器 (show_status)
- 即時顯示系統狀態
- 監控處理進度
- 顯示佇列狀態
- 使用 Python 標準庫
- 多執行緒並行處理
- 佇列管理機制
- 異常處理機制
- CSV 檔案操作
- Python 3.6 或更高版本
- 僅使用 Python 標準庫,無需額外安裝套件
-
直接執行程式:
python customer_processing.py
-
程式執行過程:
- 自動生成 5 位顧客資料
- 即時顯示處理狀態
- 自動儲存至 customer_log.csv 檔案
- 完成後自動結束
-
輸出檔案:
- 在程式執行目錄生成 customer_log.csv
- 包含時間戳記和顧客編號
程式執行時會顯示:
- 已生成的顧客數量
- 已處理的顧客數量
- 佇列中的待處理項目
- 檔案寫入狀態
- 程式設計為處理固定數量的顧客(預設 5 位)
- 可透過修改 TOTAL_CUSTOMERS 變數調整處理數量
- 執行過程中可使用 Ctrl+C 中斷程式
- CSV 檔案會在每次執行時覆寫
customer_processing.py
├── generate_customer() # 顧客生成器
├── read_card() # 資料處理器
├── save_to_file() # 資料儲存器
├── show_status() # 狀態監控器
└── main() # 主程式入口
歡迎提供改進建議和 Bug 回報。可以通過以下方式貢獻:
- 提交 Issue
- 提出改進建議
- 提交 Pull Request
本專案採用 MIT 授權協議。詳見 LICENSE 檔案。