Closed charlesedwards closed 5 years ago
asyncio.set_event_loop(asyncio.ProactorEventLoop())
util.patchAsyncio()
Reordering these two lines around should fix it (then the right event loop will get patched).
Thanks you @erdewit.!
That got rid of the error, but how do I STOP the script from running altogether when I am done?
the app.stop()
command doesnt seem to work pre my above script, it is still running?
This is the log at the end:
2018-12-10 23:31:19,631 ib_insync.wrapper DEBUG Timeout
2018-12-10 23:31:19,631 ib_insync.Watchdog DEBUG Soft timeout
2018-12-10 23:31:19,631 ib_insync.connection DEBUG >>> 20,43,0,EUR,CASH,,0.0,,,IDEALPRO,,USD,,,0,,5 secs,30 S,0,MIDPOINT,1,0,,
2018-12-10 23:31:21,799 ib_insync.client DEBUG <<< 4,2,-1,2106,HMDS data farm connection is OK:cashhmds
2018-12-10 23:31:21,799 ib_insync.wrapper INFO Warning 2106, reqId -1: HMDS data farm connection is OK:cashhmds
2018-12-10 23:31:22,184 ib_insync.client DEBUG <<< 17,43,20181210 23:30:49,20181210 23:31:19,7,20181210 23:30:45,1.142075,1.142125,1.142015,1.142015,-1,-1.00000,-1,20181210 23:30:50,1.142015,1.142055,1.142005,1.142015,-1,-1.00000,-1,20181210 23:30:55,1.142015,1.142075,1.142015,1.14207,-1,-1.00000,-1,20181210 23:31:00,1.14207,1.14207,1.142015,1.142015,-1,-1.00000,-1,20181210 23:31:05,1.142015,1.142025,1.14199,1.14199,-1,-1.00000,-1,20181210 23:31:10,1.14199,1.142015,1.141945,1.141955,-1,-1.00000,-1,20181210 23:31:15,1.141955,1.141955,1.141945,1.14195,-1,-1.00000,-1
2018-12-10 23:31:24,623 ib_insync.Watchdog INFO Stopping
2018-12-10 23:31:24,624 ib_insync.ib INFO Disconnecting from 127.0.0.1:7496, 182 B sent in 7 messages, 16.3 kB received in 326 messages, session time 135 s.
2018-12-10 23:31:24,624 ib_insync.client INFO Disconnected
2018-12-10 23:31:24,624 ib_insync.Watchdog INFO Stopping
2018-12-10 23:31:24,624 ib_insync.IBC INFO Terminating
2018-12-10 23:31:24,867 asyncio ERROR Task was destroyed but it is pending!
task: <Task pending coro=<Watchdog._watchAsync() running at C:\ProgramData\Anaconda3\lib\site-packages\ib_insync\ibcontroller.py:434> wait_for=<Future pending cb=[Task.__wakeup()]>>
This only place were app.stop() can block is when it waits for the TWS process to be terminated. I'm not sure what can go wrong there.
@erdewit, I am trying to finish the script; i.e. shutdown TWS and Stop the script.
I thought app.stop()
would do this, but it appears not? What should I have at the bottom of the script to close TWS and end the script?
I think this may be a bug associated with app.stop()
and ibc.terminate
- I have tried both approaches (calling IBC alone and using WATCHDOG) and it appears the process gets stuck in these steps.
Hi,
I am new to ib_insync and LOVE your platform, great work!
This may be an issue on my behalf, but trying to use IBC and ib_insync to launch the TWS platform... run some code... then close the tws platform, but I get the below error:
If it helps, my code is as follows: