stata_kernel icon indicating copy to clipboard operation
stata_kernel copied to clipboard

How to make jupyter automatically close the stata session

Open Gritbadger opened this issue 3 years ago • 1 comments

Hi,thank you for writing stata_kernel, which is very convenient to use. I can use python's powerful data functions and stata's powerful statistical functions at the same time.

But there is a problem, that is, whenever I use jupyterlab to create a new stata notebook, execute the stata command, and finally close the stata notebook, but jupyter will not automatically close the stata process, I have to enter the Windows task window every time, and manually close the stata process, which makes me Very convenient. Is there a way to fix this?

Gritbadger avatar Apr 14 '22 00:04 Gritbadger

Looks like this is supposed to be handled through do_shutdown. We do call self.stata.shutdown() https://github.com/kylebarron/stata_kernel/blob/b7cd97223827fa095c27774d7b6b81434ac4b97c/stata_kernel/kernel.py#L340 which tries to run exit, clear in Stata: https://github.com/kylebarron/stata_kernel/blob/b7cd97223827fa095c27774d7b6b81434ac4b97c/stata_kernel/stata_session.py#L577-L578

Not sure off the top of my head why that wouldn't work in Windows. Maybe config.get('execution_mode') isn't set properly on Windows. We could switch that to if is_windows() or config.get('execution_mode') == 'automation':

kylebarron avatar Apr 15 '22 01:04 kylebarron