After "zrok disable" error messages

When I disable environment with:
!/kaggle/working/zrok/zrok disable

I get confirmation that environment is disabled:

/kaggle/working/zrok
zrok environment disabled...

But my share listener which is defined like this:

cmd = f"/kaggle/working/zrok/zrok share public http://localhost:7801 --headless"
    get_ipython().system(cmd)

is not killed and is sending error messages non-stop, so I have to stop kaggle session every time to get rid of these error messages.

What am I doing wrong? Please help!
How can I terminate the zrok share process before calling zrok disable ?

This is little part of error messages which I get in the output:

[   6.759]    INFO sdk-golang/ziti.(*listenerManager).createSessionWithBackoff: {session token=[24ad73e5-cb0b-4ce6-bfca-13920c04273e]} new service session
[   7.320]    INFO main.(*sharePublicCommand).run: access your zrok share at the following endpoints:
 https://9mh6g4yy83db.share.zrok.io/
[  92.917]   ERROR sdk-golang/ziti/edge/network.(*edgeListener).close: {sessionId=[24ad73e5-cb0b-4ce6-bfca-13920c04273e] error=[channel closed] connId=[3]} unable to unbind session for conn
[  92.917]   ERROR sdk-golang/ziti/edge/network.(*edgeConn).close: {connId=[3] marker=[] error=[channel closed] serviceName=[9mh6g4yy83db]} failed to close listener
[  97.773]   ERROR sdk-golang/ziti/edge/network.(*edgeConn).listen [ch{ziti-sdk[router=tls:60042e42-5eef-4378-9ade-538b5cde57a0.production.netfoundry.io:443]}->u{classic}->i{rKaEp}]: {error=[timeout waiting for message reply: context deadline exceeded] connId=[3] serviceName=[9mh6g4yy83db] sessionId=[cm5wb8s2r7g8wamqciu929a59]} failed to bind
[  97.773]   ERROR sdk-golang/ziti/edge/network.(*edgeConn).unbind [ch{ziti-sdk[router=tls:60042e42-5eef-4378-9ade-538b5cde57a0.production.netfoundry.io:443]}->u{classic}->i{rKaEp}]: {error=[channel closed] connId=[3] serviceName=[9mh6g4yy83db] sessionId=[cm5wb8s2r7g8wamqciu929a59]} unable to send unbind msg for conn
[  97.773]   ERROR sdk-golang/ziti/edge/network.(*routerConn).Listen: {error=[timeout waiting for message reply: context deadline exceeded] connId=[3] router=[AWS US-West-1-1(custom config)] serviceId=[3E9W59WNX0IvP5wDsWq9AS] serviceName=[9mh6g4yy83db]} failed to establish listener
[  97.773]   ERROR sdk-golang/ziti.(*listenerManager).createListener: {serviceName=[9mh6g4yy83db]} creating listener failed after 5001ms: timeout waiting for message reply: context deadline exceeded
[  97.773]    INFO sdk-golang/ziti/edge/network.(*multiListener).NotifyOfChildError: notify error handler of error: timeout waiting for message reply: context deadline exceeded
[ 102.929]   ERROR sdk-golang/ziti/edge/network.(*edgeConn).listen [ch{ziti-sdk[router=tls:ed9935f5-5d9d-4898-a3cf-4a8a05b4e4a6.production.netfoundry.io:443]}->u{classic}->i{bwpay}]: {sessionId=[cm5wb8s2r7g8wamqciu929a59] error=[timeout waiting for message reply: context deadline exceeded] connId=[1] serviceName=[9mh6g4yy83db]} failed to bind
[ 102.929]   ERROR sdk-golang/ziti/edge/network.(*routerConn).Listen: {error=[timeout waiting for message reply: context deadline exceeded] connId=[1] router=[Public OCI Singapore(custom config)] serviceId=[3E9W59WNX0IvP5wDsWq9AS] serviceName=[9mh6g4yy83db]} failed to establish listener
[ 102.930]   ERROR sdk-golang/ziti.(*listenerManager).createListener: {serviceName=[9mh6g4yy83db]} creating listener failed after 5000ms: timeout waiting for message reply: context deadline exceeded

Do you want your Python program to catch a process signal like TERM or handle some other trigger to clean up your temporary public share and finally disable the zrok environment?

When you launch your zrok share, using this line of code:

get_ipython().system(cmd)

You are launching a separate process for zrok share. You will need to do the inverse of that, whatever it might be for your environment to terminate the share process. Terminating the share process will remove the share from zrok and clean up the resources that it is using.

zrok disable just removes the credentials and virtual environment, and does not terminate individual shares.

I did a little digging. Assuming this is running in a Jupyter Notebook... it doesn't really look like it provides much in the way of facilities for managing long-running processes like this.

Could it be as simple as doing something like !killall zrok when you want to stop your zrok share, before calling zrok disable?