Closed amircp closed 5 months ago
Hello, I've noticed that when I don't use the logout method in my class or Jupyter Notebook, the session with the broker persists, and you cannot log in again. As a consequence, you have to wait until it expires (in my case, up to 5 hours).
This will fix it (inside the cTrader class)
def __del__(self): self.logout()
(i've forked the repo and created a commit for it, if this is not the right approach i won't create the PR)
Cheers.
Could you verify if the session persists even after invoking the api.logout() method?
checkConnection = api.isconnected()
print("Is Connected?: ", checkConnection)
time.sleep(1)
Could you verify if the session persists even after invoking the api.logout() method?
Hello! Yeah! it works. The problem i was mentioning is related to halting unexpectedly the application, scenarios:
It makes sense? so in order to avoid this behavior we run the logout method in del magic method. (the object destroy method)
I'm going to create a PR for this and let you decide to include it or not.
Could you verify if the session persists even after invoking the api.logout() method?
Hello! Yeah! it works. The problem i was mentioning is related to halting unexpectedly the application, scenarios:
- If i run the library using Jupyter notebook and by mistake re-run everything (without invoking the logout method) the last session will persist so you cannot connect again until the connection times out.
- If i implement the library into my framework or any class and i stop the script (ctrl + c) or an unhandled exception is generated the session with the broker persists. (is like the broker keeps thinking the client is still there and keeps the tcp connection opened)
It makes sense? so in order to avoid this behavior we run the logout method in del magic method. (the object destroy method)
I'm going to create a PR for this and let you decide to include it or not. great thank you!!!!!
Hello, I've noticed that when I don't use the logout method in my class or Jupyter Notebook, the session with the broker persists, and you cannot log in again. As a consequence, you have to wait until it expires (in my case, up to 5 hours).
This will fix it (inside the cTrader class)
(i've forked the repo and created a commit for it, if this is not the right approach i won't create the PR)
Cheers.