0

i always use Stackoverflow to find solutions to my code questions, however this one i can figure it out, and i don't find any solution.

I am trying to run the following code:

import sys 
import fxcmpy

con = fxcmpy.fxcmpy(access_token='47ca0389967856f573ed02dc11a1ad1b446c072e',log_level='debug',server='demo')

sys.exit(1)

I know it seems simple, but i am trying to "force" the exit, you see the variable con is not going to work because token is incorrect, so i wanted the script to exit, pretty simple right? The problem is, i can do everything after the constructor, prints, operations, etc, but if i use exit the script freezes.

Stuck on exit

I kow that the library FXCMPY uses the library python-socketio. And it seems a socket was stablished, is it the reason why i cant exit?

Can anyone help? How to force the Interpreter to exit? Let me know if you need more info.

Best Regards, Jorge Nunes

  • See the duplicate question's answer about multithreaded programs. – AKX Jul 01 '20 at 12:43
  • Looks like the connection is being handled in a separate thread, which doesn't end until the connection is closed - thus preventing your program from exiting, even though the main thread has exited. And apparently the invalid token condition is NOT actually closing the connection, so you're stuck until the server times you out - which could be a LONG time... I would describe this as a bug in the library you're using. – jasonharper Jul 01 '20 at 12:53
  • Thank you @AKX for the link, to the other question, after reading the reply i used `os._exit(*errorcode*)` to force the exit. But like @jasonharper said, it's in a wait state and it seems like the library has a bug... – Jorge Nunes Jul 01 '20 at 13:53

0 Answers0