Hi,
when trying to pause an experiment that accesses the core (here the CorePause form the examples) by another experiment that also accesses the core, I get the following error (interrupting the CorePause experiment by one that does not access the core works fine):
INFO:worker(2031,CorePause.py):print:main kernel loop running...
INFO:worker(2031,CorePause.py):print:kernel exiting
ERROR:worker(2031,CorePause.py):root:Terminating with exception (ConnectionResetError: Core device connection closed unexpectedly)
Traceback (most recent call last):
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/master/worker_impl.py", line 343, in main
exp_inst.run()
File "/media/quasirio/ARTIQ/ARTIQ/artiq-master/repository/test_hardware/CorePause.py", line 21, in run
self.k()
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/language/core.py", line 54, in run_on_core
return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/core.py", line 140, in run
self._run_compiled(kernel_library, embedding_map, symbolizer, demangler)
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/core.py", line 128, in _run_compiled
self.comm.load(kernel_library)
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/comm_kernel.py", line 379, in load
self._read_header()
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/comm_kernel.py", line 249, in _read_header
sync_byte = self._read(1)[0]
File "/nix/store/lw7vwas2i4y4hknnyk8xb2kblx34v94k-python3-3.9.13-env/lib/python3.9/site-packages/artiq/coredevice/comm_kernel.py", line 237, in _read
raise ConnectionResetError("Core device connection closed unexpectedly")
ConnectionResetError: Core device connection closed unexpectedly

The coremgmt log is as follows:
[ 2371.732551s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2373.910009s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2376.087859s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2378.282564s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2380.459153s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2382.633719s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2384.802419s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2386.050201s] INFO(runtime::session): new connection from 10.33.21.156:45746
[ 2386.056410s] INFO(runtime::session): kernel interrupted
[ 2386.105430s] INFO(runtime::kern_hwreq): resetting RTIO
[ 2386.121234s] INFO(runtime::session): no connection, starting idle kernel
[ 2386.127151s] INFO(runtime::session): no idle kernel found
[ 2395.453821s] INFO(runtime::mgmt): new connection from 10.33.21.156:34994

CorePause experiment (submitted with priority 0):
`from time import sleep
from artiq.experiment import *

class CorePause(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("scheduler")

@kernel
def k(self):
    print("kernel starting")
    while not self.scheduler.check_pause():
        print("main kernel loop running...")
        sleep(1)
    print("kernel exiting")

def run(self):
    while True:
        self.k()
        self.scheduler.pause()`

and the interrupting experiment (submitted with priority 1):
`
from artiq.experiment import *

class zotinoLED(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("dac") # this is the zotino dac device

@kernel
def run(self):
    self.core.reset()           # Clears the core
    self.dac.init()             # Initializes Zotino
    delay(1*ms)                 # Delay
    
    self.dac.set_leds(255)      # turn on all leds (led = 11111111 in binary)
    delay(3*s)                  # All leds will stay on for 3 seconds
    self.dac.set_leds(0)`

I'm out of ideas how to fix it, help is very appreciated.

Please format your post correctly.

The core device can only run one kernel at once. Your "interrupting" experiment is trying to run another kernel.

actually the coremgmt log is the following one (sorry for the confusion):
[ 4921.921688s] INFO(runtime::session): new connection from 10.33.21.156:49162
[ 4921.927959s] INFO(runtime::session): kernel interrupted
[ 4921.976631s] INFO(runtime::kern_hwreq): resetting RTIO
[ 4921.992240s] INFO(runtime::session): no connection, starting idle kernel
[ 4921.998159s] INFO(runtime::session): no idle kernel found
[ 4929.154979s] INFO(runtime::mgmt): new connection from 10.33.21.156:47636

Yes, however experimenting with self.core.comm.close() didn't work for me (maybe I just didn't use it correctly). The second experiment runs without error.
I guess my problem is how to properly exit and reconnect to the kernel.