I am trying to use python forexconnect package.
I noticed that every time I call get_history method, a new thread is created.
Here is the sample code:
- Code: Select all
from forexconnect import fxcorepy, ForexConnect
TIME_FRAME = 'm1'
ALIGNING = fxcorepy.O2GCandleOpenPriceMode.PREVIOUS_CLOSE
FXCM_URL = 'fxcorporate.com/Hosts.jsp'
def session_status_changed(session, status):
if status == 'DISCONNECTED':
exit(1)
def run():
login = <your login>
password = <your password>
connection = 'demo'
with ForexConnect() as fx:
fx.login(login, password, FXCM_URL, connection, None, None,
session_status_changed)
for i in range(500):
print(i)
fx.get_history('EUR/USD', TIME_FRAME, None, None, 3, ALIGNING)
if __name__ == "__main__":
run()
input()
When the loop finishes, the python process has more than 500 threads.
Checked it with ps
- Code: Select all
ps huH p <PID> | wc -l
Am I doing something wrong? Is it normal?