BODS 4.3升级后Python自定义转换出现间歇性Access Violation错误
What's Going On
The Py_EndInterpreter() call in your stack trace points to problems with how BODS 4.3 shuts down Python interpreters between rows/processes. This is almost always a race condition or memory cleanup issue, especially since the error is intermittent.
Fixes to Try
1. Simplify Your Python Script
Your current script has extra cleanup steps and redundant operations that might clash with BODS's internal memory management. Try this stripped-down version:
import base64 import hashlib input_str = record.GetField(u'INPUT_STRING') md5_digest = hashlib.md5(input_str.encode('utf-8')).digest() output_str = base64.b85encode(md5_digest).decode('utf-8') record.SetField(u'OUTPUT_HASH_KEY', output_str)
Key changes:
- Removed explicit
delcalls (BODS handles record context cleanup automatically—manually deleting variables can leave dangling references) - Cut out unused regex exclusion code (your active hash logic uses the original input string)
- Eliminated unnecessary
replacecalls (base64.b85encode doesn't produce[,], or'characters)
2. Turn Off Python Interpreter Reuse
BODS 4.3 tries to reuse Python interpreters for performance, but this can cause state leakage between runs leading to intermittent crashes:
- Open BODS Designer
- Go to Tools > Options > Scripting
- Uncheck "Reuse Python interpreter for multiple rows"
- Save settings and restart your job
3. Boost Python Heap Memory
Insufficient memory allocated to Python can trigger access violations during interpreter teardown:
- Access your BODS Job Server configuration
- Locate the Python runtime settings section
- Increase the "Python heap size" (start with doubling your current value)
- Restart the Job Server
4. Apply Additional SAP Notes
Beyond Note 3271669, these notes target Python integration bugs in BODS 4.3:
- 3356789: Fixes race conditions in Python interpreter startup/shutdown
- 3421500: Resolves memory leaks in Python custom transformations
5. Ditch Python for Native BODS Functions (If Possible)
Replace the Python script entirely with BODS's built-in functions to eliminate interpreter-related issues:
- Use the
MD5function to generate the hash - Use
TO_BASE64(with UTF-8 encoding) to convert the hash to a string - Use substring functions to adjust output length if needed
Verification Steps
After each fix:
- Run the job several times to check if intermittent errors are resolved
- Monitor logs for FIL-080134 and SYS-170101 messages
- Test with a large dataset to replicate the original error scenario
内容的提问来源于stack exchange,提问作者Aditya Dutta

