Session

Factory methods

Session creation/deletion should always be done using factory methods.

from chipscopy import create_session

CS_URL = "TCP:localhost:3042"
HW_URL = "TCP:localhost:3121"

session = create_session(cs_server_url=CS_URL, hw_server_url=HW_URL)
from chipscopy import delete_session

delete_session(session)

Alternatively, context managers like with can be used to auto manage session lifecycle as shown in below example

from chipscopy import create_session

CS_URL = "TCP:localhost:3042"
HW_URL = "TCP:localhost:3121"

with create_session(cs_server_url=CS_URL, hw_server_url=HW_URL) as session:
    # Your business logic here
    device = session.devices.at(0)

# 'session' is automatically deleted after the with block gets done
print()

Reference