OTMql4Py
OTMql4Py copied to clipboard
iPyEvalInt("os.getpid()") cause MT4 hang
In OTPyTestNullEA.mq4
int OnInit(){
...
...
iRetval = iPyEvalInt("os.getpid()"); //cause mt4 hang
}
Log file: 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] vPyInit - Opened d:\MT4\MQL4\Python\OTMql427../../Logs/_test_PyTestNullEA.txt d:\MT4\MQL4\Python\OTMql427../../Logs/_test_PyTestNullEA.txt vPyInit - Thread MainThread number 1556 Exception KeyError: KeyError(3528,) in <module 'threading' from 'C:\Python27\Lib\threading.pyc'> ignored
Work around by not a good solution:
//iRetval = iPyEvalInt("os.getpid()");
//replace as
iRetval = uPySafeEval("os.getpid()");
Essential information for reporting Issues:
- Windows Server 2012R2, 64 bit:
- Metatrader Build: 101
- Metatrader installed from: d:\mt4 (run as portable mode)
- Version of Python: 2.7.12
- Python installed from: c:\python27
- OTMql4Py from git, or what version of the OTMql4Py installer: (latest)
I'm facing the same issue. After execution of OTPyTestNullEA.mq4 my log shows:
2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:19:22) [MSC v.1500 32 bit (Intel)] vPyInit - Opened C:..\MetaQuotes\Terminal..\MQL4\Python\OTMql427../../Logs/_test_PyTestNullEA.txt C:..\MetaQuotes\Terminal..\Python\OTMql427../../Logs/_test_PyTestNullEA.txt vPyInit - Thread MainThread number 4876 ERROR:root:5584 - 4876 - <_MainThread(MainThread, stopped 4876) Traceback (most recent call last): File "C:\Program Files (x86)\Python27\Lib\threading.py", line 1104, in _exitfunc self._Thread__delete() File "C:\Program Files (x86)\Python27\Lib\threading.py", line 894, in __delete del _active[_get_ident()] KeyError: 5584
After enhancing exception handling in threading.py it seems to me that the _get_ident() returns the wrong ThreadId. The MainThread id is 4876. The function at this point returns 5584. Refer to stackoverflow this issue could be triggered by monkey pathing.
- Windows 8, 64 bit
- Metatrader Build: 1031
- Python 2.7.12
- OTMyl4Py by installer